Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update npm

Tags:

npm

ubuntu

I'm trying to install mean.io boilerplate. It fails when running sudo npm install -g meanio@latest. Prior to failing it notes that it 'wants' npm version 1.4.x, whereas I have 1.2.18 installed. So I tried updating npm to the latest; several ways. Last of which was...

ubuntu@ip-xxx-xx-xx-xxx:~$ sudo npm install -g npm /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js [email protected] /usr/local/lib/node_modules/npm  ubuntu@ip-xxx-xx-xx-xxx:~$ npm --version 1.2.18 

Why is it still showing version 1.2.18, when I just updated to 1.4.7?

like image 957
user3567174 Avatar asked Apr 30 '14 16:04

user3567174


People also ask

How do I get the latest version of npm?

Go into %ProgramFiles%\nodejs\node_modules\npm and copy the file named npmrc in the new npm folder, which should be %appdata%\npm\node_modules\npm . This will tell the new npm where the global installed packages are.

How install npm latest?

Method 1: Using npm update command to update the node package manager. Method 2: Using npm@latest command to update the node package manager. Method 3: Using PPA repository (only for Linux). Method 4: Using cache cleaning & stable installing (only for Linux).

How do I update npm and NVM?

nvm now has a command to update npm. It's nvm install-latest-npm or nvm install --latest-npm . nvm install-latest-npm : Attempt to upgrade to the latest working npm on the current Node.


1 Answers

This will update npm using npm itself:

sudo npm install npm -g 

If you are stuck, try sudo npm update npm -g. All credit goes to Tim Castelijns. I have tested it on ubuntu 14.04, npm 1.3.10


Note that if you are using nvm for managing multiple versions in your local dev environment for e.g. testing purposes, all your installed versions (listed by nvm ls) are in ~/.nvm, hence you just omit system wide installation (i.e. omit sudo):

npm install npm -g 

DEBIAN ENTERPRISE

For full enterprise practice consider nodesource.com:

curl -sL https://deb.nodesource.com/setup | sudo bash -

as described here.

OTHER ENTERPRISE

For non-debian distributions check out on the node github wiki https://github.com/joyent/node/wiki/installing-node.js-via-package-manager download page https://nodejs.org/en/download/

For historical understanding: Chis Lea was maintaining his PPA but now joined forces with nodesource.

like image 191
Yauhen Yakimovich Avatar answered Oct 07 '22 09:10

Yauhen Yakimovich