couldn't install npm on ubuntu
Tried to install nodejs and npm on ubuntu 12.04. I googled and did it. Now, I could not install npm on machine.
sudo apt-get install npmWhich gives me this
The following packages have unmet dependencies: npm : Depends: nodejs but it is not going to be installed Depends: nodejs-dev Depends: node-request but it is not going to be installed Depends: node-mkdirp but it is not going to be installed Depends: node-minimatch but it is not going to be installed Depends: node-semver but it is not going to be installed Depends: node-ini but it is not going to be installed Depends: node-graceful-fs but it is not going to be installed Depends: node-abbrev but it is not going to be installed Depends: node-nopt but it is not going to be installed Depends: node-fstream but it is not going to be installed Depends: node-rimraf but it is not going to be installed Depends: node-tar but it is not going to be installed Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages. 3 9 Answers
This looks like you probably installed the chris-lea node.js ppa which is fine. However, you don't install npm from that ppa as it breaks the way debian packages work. Instead, just install nodejs. Once that's installed, run npm -v you should see it's now installed. If you didn't use the chris-lea ppa update your question on what webpage you Googled to find out how to install nodejs on Ubuntu.
Try installing NodeJs like this:
sudo apt-get install nodejsSince NodeJs installs node and npm
2Apt doesn't handle dependancy conflicts well, use snap or aptitude;
sudo aptitude install npm
I had to press "no" to the first solution it proposed, which did not include installing npm (that must be a bug in aptitude) then the second solution I pressed yes to
hTHen check npm was installed:
npm --version
Problem is registry, execute this command,
npm config set registry I work on this way, check it work for you
3I solved this issue by following this documentation.
Pointers to remember to work with npm:
mkdir ~/nodejs/ && cd ~/nodejs
sudo apt-get install npm
npm install
npm updateWhile developing applications, if nodejs needs any particular module then run
cd ~/nodejs
npm install modulename #for example sendgridSometimes, modules needs to install globally; then use
sudo npm install modulename -g"To remove a module:
cd ~/nodejs
npm uninstall modulename # if locally installed or
sudo npm uninstall modulename -g # if globally installednpm prune helps to remove unmet dependencies
First, you need to install the PPA in order to get access to its contents:
curl -sL | sudo bash -(This for version 9, which is the latest version at the time of writing).
And then
sudo apt-get install nodejs Version conflict of manual installed npm and which comes with latest nodejs.
So you could try to remove nodejs, remove old npm and installed new nodejs again which comes with npm.
it worked in my case.
first-:
curl -o- | bashthen logout and come again and
nvm install nodeit will install npm . hope it will help
Installing nodejs will install npm, so just remove nodejs then reinstall it:
sudo apt-get remove nodejs