I have install node/npm using the nvm documentation.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
I then install it:
nvm install stable
and then I have to do:
nvm use node
npm is working but if I want to install a package globally it doesn't work.
sudo npm install -g package
I've got this:
sudo: npm: command not found
I've seen many topic but I didn't really understand anything with symbolic link or something like this. I'm using ubuntu 14.04
What is the NVM. The NVM meaning is node version manager, according to the official document, something we can know: This way is more recommend than node installer. You can install and switch between multiple versions of node and npm in your device.
Any global installs will cache packages to /root/. npm instead of root -owned files at /home/me/. npm . Just always use sudo -i or sudo -H when running npm install to install global packages and your npm permissions problems will melt away.
nvm manages node. js and npm versions. It's designed to be installed per-user and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
nvm
maintainer here - with http://nvm.sh, you should never need to use sudo.
Also, nvm
is per-user - meaning, the sudo
user won't have it in its shell environment, and its PATH won't be set up properly anyways.
Just do npm install -g package
and it will work perfectly :-)
Also, if you do nvm alias default node
, you won't have to nvm use
every time you open up a new shell!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With