Ojrojako
Ojrojako

Reputation: 75

A new version of npm has been installed, but the old one is still being used

I was shown this when I was installing dependencies for a project:

 Update available 5.7.1 → 5.8.0    │
   │       Run npm i npm to update       

Then I did this:

$ npm i npm
npm WARN [email protected] requires a peer of react@>=0.11.0 || ^0.14.0-rc but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 523 packages from 726 contributors in 12.75s

But why is it still the old version?

$ npm --version
5.7.1

Upvotes: 3

Views: 5770

Answers (2)

KiritoLyn
KiritoLyn

Reputation: 760

As a reference from Robert Baker's answer Here,

  1. Run PowerShell as Admin
  2. Run the following codes:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-upgrade npm-windows-upgrade

Note: Do not run npm i -g npm. Instead use npm-windows-upgrade to update npm going forward. Also if you run the NodeJS installer, it will replace the node version.

I was able to upgrade from 5.6 to 6.7 (latest version from the writing of this comment)

Upvotes: 0

MBlanc
MBlanc

Reputation: 1783

But why is it still the old version?

By default, npm installs packages in the local node_modules/ directory. Since npm i npm is shorthand for npm install npm, it will install the latest version of npm locally.

However, when run npm in a shell, the shell picks up the npm in your $PATH, which is probably the global installation.


To update the global installation of npm, run:

npm install --global npm

You'll also probably will want to delete the local installation of npm to reduce bloat:

npm uninstall npm

See How can I update Node.js and npm to the next versions? for more information on updating.

Upvotes: 5

Related Questions