node.js - specific - update npm windows
How can I update NodeJS and NPM to the next versions? (20)
I just installed
npm (for additional modules).
How can I update Node.js and the modules which I'm using to the latest versions?
npm do it, or do I have to remove and reinstall Node.js and npm to get the next versions?
I followed this steps in the
First check your NPM version
1) Update NPM to current version:
View curent NPM version:
npm view npm version
Update npm to current version:
npm i -g npm
2) List all available NPM versions and make a custom install/update/roll-back
View all versions including "alpha", "beta" and "rc" (release candidate)
npm view npm versions --json
Reinstall NPM to a specific version chosen from the versions list - for example to 5.0.3
npm i -g [email protected]
Installing one version will automatically remove the one currently installed.
For Linux and iOS prepend commands with sudo
Upgrading for Windows Users
Windows users should read Troubleshooting > Upgrading on Windows in the npm wiki.
Upgrading on windows 10 using PowerShell (3rd party edit)
The link above Troubleshooting#upgrading-on-windows points to a github page npm-windows-upgrade the lines below are quotes from the readme. I successfully upgraded from npm 2.7.4 to npm 3.9.3 using node v5.7.0 and powershell (presumably powershell version 5.0.10586.122)
First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Then, to install and use this upgrader tool, run (also from an elevated PowerShell or cmd.exe):
npm install --global --production npm-windows-upgrade npm-windows-upgrade
Install npm =>
sudo apt-get install npm
Install n =>
sudo npm install n -g
latest version of node =>
sudo n latest
Specific version of node you can
List available node versions =>
Install a specific version =>
sudo n 4.5.0
As you may know, NPM is currently bundled with Node.js, it means that if you have installed
node you already have installed
npm. There are several approaches to keep up to date the Node.js and NPM, you need to use one of the following version managers:
If yo are on Mac, you can use Homebrew. To install NodeJS and NPM using brew:
$ brew install node
later you will be able to update it using
$ brew update && brew upgrade node
NPM will be updated as well.
You also will be able to
switch to the one of the previous versions if you need, for example:
$ brew switch node 0.10.26
To install brew to your Mac:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
n is most likely to
rvm (Ruby Version Manager), and can be used to manage and update
Install Node.js versions easily:
$ n 0.10.26 $ n 0.8.17 $ n 0.9.6
Use (and install if missing) the latest official release:
$ n latest
Use/install the stable official release:
$ n stable
Switch to the previous version you were using:
$ n prev
If you want to see the list of installed nodes, just run
n from your command line, the output will be something like the following:
$ n 0.10.26 • 0.8.17 0.9.6
The dot (•) means that it's a currently active version. To select a node version from the list use
down arrows and activate using
n package is written on pure
linux shell and available as a npm module (contains
package.json), so if you have any Node.js installed, you can install/update the
n through the
$ npm install -g n
nvm is also like
RVM, even the command names and usage are very similar.
To download, compile, and install the latest v0.10.x release of the Node.js using
$ nvm install 0.10
And then you can switch to the installed version:
$ nvm use 0.10
You can create an
.nvmrc file containing version number in the project root folder; then run the following command to switch to the specified version:
$ nvm use
Or you can just run it:
$ nvm run 0.10
If you want to see which versions are already installed, use:
$ nvm ls
nvm itself you can use the install script (requires
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
All these approaches I've used on MacOSX and Linux, I don't have any experience on how to manage Node.js versions on Windows, I can only suppose that the
n (the second one) will work for Microsoft's OS (at least from the
Here is a simple fix for those who installed
node via Homebrew without
npm and later on struggled with
npm upgrade/installation using an official script. This approach assumes you have run the
node installation as follows:
brew install node --without-npm echo prefix=~/.npm-packages >> ~/.npmrc curl -L https://www.npmjs.com/install.sh | sh
If above failed then start from here. Remove
npm if any:
rm -rf ~/.npm-packages/lib/node_modules/npm
Download and unpack the latest version of
npm, currently at 5.6.0:
cd ~ curl -L https://registry.npmjs.org/npm/-/npm-5.6.0.tgz | tar xz
Move unpacked package into node_modules folder:
mv ~/package ~/.npm-packages/lib/node_modules/npm
Make sure your
~/.bash_profile has following entries:
export NPM_PACKAGES="$HOME/.npm-packages" export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH" export PATH="$NPM_PACKAGES/bin:$PATH"
Source the file:
I just installed Node.js on a new Windows 7 machine, with the following results:
> node -v v0.12.0 > npm -v 2.5.1
I then did the above described procedure:
> npm install -g npm
and it upgraded to v2.7.3. Except than doing
npm -v still gave 2.5.1.
I went to the System configuration panel, advanced settings, environment variables. I saw a PATH variable specific to my user account, in addition to the global Path variable.
The former pointed to new npm:
The latter includes the path to node:
C:\PrgCmdLine\nodejs\ (Nowadays, I avoid to install stuff in Program Files and derivates. Avoiding spaces in paths, and noisy useless protections is saner...)
If I do
which npm.cmd (I have Unix utilities installed...), it points to the one in Node.
Anyway, the fix is simple: I just copied the first path (to npm) just before the path to node in the main, global Path variable, and now it picks up the latest version.
<some stuff before>;C:\Users\PhiLho\AppData\Roaming\npm;C:\PrgCmdLine\nodejs\
> npm -v 2.7.3
I recently stumbled across this article: http://martineau.tv/blog/2013/12/more-efficient-grunt-workflows/ and the author mentions
$ npm-check-updates -u && npm install to update all dependencies.
This is a little off the topic but I ended up here on a similar search so thought it was worth the share.
If you're using Windows: Go to https://nodejs.org/en/download/, download latest
.msi file and install to overwrite the old versions
If you're using Ubuntu or Linux: Uninstall
node.js first then reinstall, e.g with Ubuntu ():
sudo apt-get remove nodejs # assume node.js 8 is latest version curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install nodejs node -v npm -v
node_modules in your project folder and
npm install to make sure your application will run well on new
Just run the below scripts on console:
sudo npm i -g n sudo n stable sudo npm update -g npm
This will work for Linux and MAC only
Just run the following command in terminal as root/administrator:
npm i -g n n stable npm update -g npm
It has worked for me on Linux
See the docs for the
npm update [<name> [<name> ...]]
This command will update all the packages listed to the latest version (specified by the tag config). It will also install missing packages.
Additionally, see the FAQ:
How do I update npm?
npm install -g npm
Please note that this command will remove your current version of npm. Make sure to use
sudo npm install -g npmif on a Mac.
You can also update all outdated local packages by doing
npm updatewithout any arguments, or global packages by doing
npm update -g.
Occasionally, the version of npm will progress such that the current version cannot be properly installed with the version that you have installed already. (Consider, if there is ever a bug in the update command.) In those cases, you can do this:
curl https://www.npmjs.com/install.sh | sh
To update Node.js itself, I recommend you use nvm, the Node Version Manager.
Updating npm is easy:
npm install [email protected] -g
Use n module from npm in order to upgrade node . n is a node helper package that installs or updates a given node.js version.
sudo npm cache clean -f sudo npm install -g n sudo n stable sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs
NOTE that the default installation for nodejs is in the /usr/bin/nodejs and not /usr/bin/node
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n
If you get the following error
bash: /usr/bin/node: No such file or directory then the path you have entered at
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs
if wrong. so make sure to check if the update nodejs has been installed at the above path and the version you are entered is correct.
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new one.
you should see this blog nodejs install with package-manager
Before you performance this command.
you show run
sudo apt-get update, make sure result is Reading package lists... Done, no ERROR
Step by Step (Debian):
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs
$ npm install -g npm stable
Worked for me to update from 1.4.28 to 2.1.5