I tried running sudo apt-get install npm
it returns me this dialogue below. How can I resolve the issue?
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
npm : Depends: node-gyp (>= 0.10.9) but it is not going to be
installed
E: Unable to correct problems, you have held broken packages.
npm gets installed along with nodejs. If you have node installed, you have npm as well.
run node -v
to check if node is installed, then run npm -v
to do the same for npm.
If nodejs is not installed, check installation instructions here: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
6.x is the current stable branch.
In general, to run a wipe existing node/npm installation and install from scratch, run:
sudo apt remove --purge nodejs node npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove
The best and easiest way to install node and npm is by nvm(node version manager).
Run the below code to install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
2.Then run
nvm install node
npm will be installed alongside node
This method will be the easiest and safest way for npm and node installation.
For installing a specific node and npm you can do it like below:
nvm install v6.11.3
Hope this helps.
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