For reasons unknown to me, I haven't been able to update to the latest version of npm on macOS (it works fine on Windows). It displays no error, only 'updated 1 package'.
Using Node.js 8.11.1
node -v v8.11.1
What version of npm do I have?
$ npm -v 5.6.0
I tried this...
$ npm i -g npm + [email protected] updated 1 package in 7.37s
And it fails to update.
$ npm -v 5.6.0
Where is npm?
$ which npm /usr/local/bin/npm
So I try brew
...
brew install npm
And it fails...
$ npm -v 5.6.0
*And then I tried this... *
npm install npm@latest -g + [email protected] updated 1 package in 7.618s
And it fails...
npm -v 5.6.0
With sudo
:
sudo npm i -g npm + [email protected] updated 1 package in 7.794s
And it fails...
npm -v 5.6.0
This also fails...
sudo npm install npm@latest -g
I followed the directions found on this Q&A, completely removing npm and node from my system and reinstalling them from scratch, and it also fails to update.
Screenshot, per request:
Close the terminal, and then re-open the terminal and running:
$ npm -v 5.6.0
sudo
twice:
$ sudo npm i -g npm + [email protected] updated 1 package in 7.478s $ sudo npm i -g npm + [email protected] updated 1 package in 7.434s
Also fails:
$ npm -v 5.6.0
What did I miss? What's going on here?
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.
Run npm-upgrade <command> --help to see usage help for corresponding command. check is the default command and can be omitted so running npm-upgrade [filter] is the same as npm-upgrade check [filter] .
To see if NPM is installed, type npm -v in Terminal. This should print the version number so you'll see something like this 1.4.
This works on my mac.
Based on docs https://docs.npmjs.com/troubleshooting/try-the-latest-stable-version-of-npm :
npm install -g npm@latest
There is a note stated on the docs that depends on your installation method, you might addd some sudo
.
Upgrading on *nix (OSX, Linux, etc.)
(You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With