Reputation: 71
What is the proper way to install NPM and NodeJS ?
Method 1 .: sudo apt-get install npm
sudo apt-get install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
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: nodejs but it is not going to be installed
Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
Depends: node-ansi but it is not going to be installed
Depends: node-archy but it is not going to be installed
Depends: node-block-stream but it is not going to be installed
Depends: node-fstream (>= 0.1.22) but it is not going to be installed
Depends: node-fstream-ignore but it is not going to be installed
Depends: node-github-url-from-git but it is not going to be installed
Depends: node-glob (>= 3.1.21) but it is not going to be installed
Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
Depends: node-inherits but it is not going to be installed
Depends: node-ini (>= 1.1.0) but it is not going to be installed
Depends: node-lockfile but it is not going to be installed
Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
Depends: node-gyp (>= 0.10.9) but it is not going to be installed
Depends: node-nopt (>= 2.1.1) but it is not going to be installed
Depends: node-npmlog but it is not going to be installed
Depends: node-once but it is not going to be installed
Depends: node-osenv but it is not going to be installed
Depends: node-read but it is not going to be installed
Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
Depends: node-request (>= 2.25.0) but it is not going to be installed
Depends: node-retry but it is not going to be installed
Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
Depends: node-semver (>= 2.1.0) but it is not going to be installed
Depends: node-sha but it is not going to be installed
Depends: node-slide but it is not going to be installed
Depends: node-tar (>= 0.1.18) 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.
======================================================================
Method 2. curl -L https://npmjs.com/install.sh | sh
curl -L https://npmjs.com/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 132 0 0:00:01 0:00:01 --:--:-- 132
100 6239 100 6239 0 0 1976 0 0:00:03 0:00:03 --:--:-- 6986
tar=/bin/tar
version:
tar (GNU tar) 1.27.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.4.1.tgz
unbuild [email protected]
npm ERR! Linux 3.13.0-44-generic
npm ERR! argv "/usr/bin/node" "/tmp/npm.14799/package/cli.js" "rm" "npm" "-gf"
npm ERR! node v0.10.36
npm ERR! npm v2.4.1
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! Error: EACCES, unlink '/usr/bin/npm'
npm ERR! { [Error: EACCES, unlink '/usr/bin/npm'] errno: 3, code: 'EACCES', path: '/usr/bin/npm' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/npm.14799/package/npm-debug.log
> [email protected] prepublish /tmp/npm.14799/package
> node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test/*/*/node_modules && make -j8 doc
make: Nothing to be done for `doc'.
npm ERR! Linux 3.13.0-44-generic
npm ERR! argv "/usr/bin/node" "/tmp/npm.14799/package/cli.js" "install" "-gf"
npm ERR! node v0.10.36
npm ERR! npm v2.4.1
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! Error: EACCES, unlink '/usr/bin/npm'
npm ERR! { [Error: EACCES, unlink '/usr/bin/npm'] errno: 3, code: 'EACCES', path: '/usr/bin/npm' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/usr/bin/npm'
npm ERR! error rolling back { [Error: EACCES, unlink '/usr/bin/npm'] errno: 3, code: 'EACCES', path: '/usr/bin/npm' }
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/npm.14799/package/npm-debug.log
It failed
In Both cases i was unable to get install npm please guide me thanks
Upvotes: 1
Views: 6690
Reputation: 74
NVM should be used.
First run
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.1/install.sh | bash
After
nvm install 0.12
This will provide you with working node. If you want to know more about other advantages of nvm - read more at https://github.com/creationix/nvm
Upvotes: 5
Reputation: 3841
Since i cant comment yet..
you need to run method 2 as root
thats why your getting EACCES
errors
sudo curl -L https://npmjs.com/install.sh | sudo sh
Upvotes: -1