Apt-get does not recognize node software installed via nvm
I'm trying to install a .deb
package however it requires several dependencies such as nodejs, nodejs-underscore, but all of those are already installed via nvm
and are available.
Is there anyway I can have apt-get
recognize packages installed via nvm so that they don't clash? I know that apt-get is system-wide whereas nvm works at local user-space so this might need some hacking.
The simplest approach, whenever possible is to only use either nvm
or .deb
packages. This will probably save you a lot of headaches in the long run, so look into that first. It seems like nearly anything node-related that is provided by a .deb
package could be installed via nvm
instead.
If that really isn't possible, however, you may be able to create "dummy" .deb
packages using equivs-control
and equivs-build
to tell apt
that you have the dependencies installed. Note that this could potentially confuse apt if you get things wrong. Also, even if you uninstall nvm
packages, apt will still think you have the substitutes you've defined in the dummy packages until you uninstall the dummy packages themselves.
First, install "equivs" so we can build the dummy packages:
sudo apt-get install equivs
Create a control file that describes the dummy package:
cd ~
equivs-control nodejs-dummy
Edit this control file:
nano nodejs-dummy
Un-comment and change lines in the control file as desired. In particular set the "Provides:" line to list the packages that you've substituted using nvm
. For example:
Package: nodejs-dummy
Version: (version slightly higher than what the apt package actually provides)
Maintainer: Your Name <[email protected]>
Provides: nodejs
Architecture: all
Description: Something that will remind you what this does ;)
Build the package:
equivs-build nodejs-dummy
Finally, install it:
sudo dpkg -i nodejs-dummy_use_the_actual_filename.deb
Rinse and repeat for whatever packages you've substituted using nvm
. If a package depends on a specific version of another package you've replaced with nvm
, you may need to use that exact version number it depends on. I'm not sure what issues might arise from do so, however, and you'll likely need to keep rebuilding your dummy packages whenever the OS packages change versions.
This is a problem with how nvm distributes software. They simply are not doing any distro specific packaging. To be specific did a quick read of nvm and they are just wget'ing binaries. For instance, here's what it installs for nodejs 6: https://nodejs.org/.../lates.../node-v6.3.1-linux-x64.tar.gz This does not contain any standard .deb or .rpm metadata so until they properly release real packages there is not much any of the distro level package managers can do and they will likely conflict with one another. If I'm understanding the point of nvm releasing proper packages is not something they are interested in exactly because it ties them to supporting distro specific packages. So instead we have the hack that is nvm. Maybe file an issue against their git. This can only be corrected by the nodejs community.
Notably npm and nvm currently seem to not support any concept of code signing(source) so when compared to distro packaging which is well supported in most distro's package managers. This is a fairly insecure approach to installing system packages.
No, you can't as you said already. Apt works at system level, where regular nvm install packages at user level.
You have two options -
Either your desired package via nvm and use the other nvm packages already intalled, or
install the package using
apt-get
and install all the dependencies with it.