Reputation: 739
My Linux distribution is:
uname -a
Linux 16.04.2-Ubuntu
Also, my npm
version was:
npm -v
3.5.2
I wanted to install version 3.10.10 of npm via this command:
sudo npm cache clean -f
sudo npm install [email protected]
But I get these errors:
npm WARN enoent ENOENT: no such file or directory, open '/home/arvin/package.json'
npm WARN myname No description
npm WARN myname No repository field.
npm WARN myname No README data
npm WARN myname No license field.
And when using the same command for installed version 6.12.2 of Node.js:
sudo npm install [email protected]
And I get these errors:
npm ERR! Linux 4.13.0-26-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "[email protected]"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! No compatible version found: [email protected]
npm ERR! Valid install targets:
npm ERR! 0.0.0
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/arvin/npm-debug.log
Finally, I decided to completely remove `npm' and Node.js via these commands:
sudo apt-get purge --auto-remove nodejs
sudo apt autoremove
sudo rm -R ~/.npm
sudo rm /usr/local/bin/npm, /usr/local/share/man/man1/node, /usr/local/lib/dtrace/node.d, ~/.node-gyp, /opt/local/bin/node, opt/local/include/node, /opt/local/lib/node_modules
sudo npm uninstall npm
So, how can I install npm v3.10.10 and Node.js v6.12.2 in Ubuntu 16.04 (Xenial Xerus)?
Upvotes: 2
Views: 19689
Reputation: 2874
If you want to use npm
to install npm
, you need to use the -g
flag to signal that the package should be installed globally. If you install without the -g flag, it will try to find a package.json
file in the local directory.
sudo npm install -g [email protected]
Btw, you cannot install Node.js with npm. To manage Node.js versions, you can use either nvm
or n
. I recommend using n.
Upvotes: 5