As I need an updated version of NodeJS, I first remove old version... By:
apt-get remove --purge nodejs
apt-get remove --purge node
apt-get autoremove
... after sucess on install last version of NodeJS, I ran the npm install procedure,
node --version # now is ok!
sudo apt-get install npm # ERROR!!!!
So, how to install npm in this context (after this purge process)
EDIT:
PS: as I show by link above and inline-comment above, nodejs --version
is OK, is good, no problem. This question was about npm
and apt-get
... And now I see that part of the answer is here.
The error messages, same as this similar question
The following packages have unmet dependencies:
npm : Depends: nodejs but it is not going to be installed
Depends: node-abbrev (>= 1.0.4)
Depends: nodejs-dev
...
Depends: ... but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
b) Reinstalling using a Node installer Using the official Node installer is the easiest way to reinstall Node. js and npm on your Windows environment. To use this option, you can go to the Node. js download page and reinstall the latest Node.
Run: “npm cache clean –force” npm cache clean --force or npm cache clean -f . This will force delete the npm cache on your computer.
... Nobody say, but the problem is not with my NodeJS or my UBUNTU, the problem is like a bug with sudo apt-get install npm
, this command is with a bug: need to fix the message.
As sayd here in similar question, the npm
was installed by the modern NodeJS's installation (!!), so apt-get must say "ok, no problem, you have a good and updated npm
".
Conclusion:
use only "curl + apt
" commands with the correct setup_N.x
choice, as illustred in all links posted here. The installation of nodejs
will install also npm
.
not use apt-get install npm
, avoid it. Is a bug.
NOTE: a typical "curl + apt
" is
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
and, after sucess with this install procedure, to check npm
existence, use
npm --version
so, if shows a version number (like 3.3.12), npm
was installed!
IMPORTANT: to update npm
(ex. from 3.3.12 to 3.5.2) not use apt-get
(!), use the npm
itself,
sudo npm install npm -g
Today, 2017, at UBUNTU 16 LTS, is possible... And using only atp
(is most friendly tham apt-get
):
sudo apt update
sudo apt install nodejs # need it first!
sudo apt install npm
... But ...it is the "most updated version of the sluggish LTS", ... check each version (!)...
Step-by-step for a specific version choice (v6.x as illustration), as this tutorial:
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
atp install nodejs
Remove nodejs and fix broken packages.
sudo apt-get --purge remove nodejs node npm
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get -f install
sudo apt-get autoremove
Install nodejs using a PPA
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Create a symbolic link for node, as many Node.js tools use this name to execute.
sudo ln -s /usr/bin/nodejs /usr/bin/node
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
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