How can I update npm itself? - node.js

I am trying to update npm itself:
npm uninstall npm -g
Responds with:
unbuild npm#2.12.1
But when I go:
npm --version
I get 1.4.28? How to upgrade the npm itself?

By using this command you can update npm to the latest release by using npm itself :
npm i -g npm#latest

You can try this:
cd /usr/lib/node_modules
npm install npm#latest
Edit:
npm install -g npm worked for me.

See which version you have
npm -v
Install the newest npm update
npm install -g npm#latest
Upgrade to the most recent release
npm install -g npm#next
Upgrading on Windows
Microsoft wrote a small command-line tool to automate the steps below. You can go and download it here
https://docs.npmjs.com/try-the-latest-stable-version-of-npm

Related

Can anyone update npm on the VS Code Terminal

I have recently updated npm on my cmd prompt in order to use yarn package manager. I want to be able to use yarn with Visual Studio Code, but I can not get the terminal in Visual Studio Code to update npm past v8.3.0
I've tried:
npm install
npm install -global npm#latest
npm install -g npm
npm i -g npm
npm update
npm update npm
npm update -g npm
npm update -global npm#latest (this command actually downgraded npm to 8.1.2)
Any help would be much appreciated
You can try to install n which is a package that lets you quick switch node version.
Install it with
sudo npm install -g n
Once installed you can select the preferred version
sudo n 8.3.0
REFERENCE: https://github.com/tj/n#installing-nodejs-versions

Cannot find module 'agentkeepalive' when updating NPM to 7.20.3

When I'm trying to update npm to 7.20.3 (npm install -g npm#7.20.3), npm throws :
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /Users/ShaggyRogers/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
...
In order to quickly fix this error just install or re-install globally agentkeepalive :
npm install -g agentkeepalive --save
Then update npm :
npm install -g npm#7.20.3
UPDATE :
Since June 23 2021, the bug seems to be fixed in v7.17.0 (GitHub issue)
You can first upgrade to v7.17.0:
npm install -g npm#7.17.0
Then upgrade to the last version of npm :
npm install -g npm#7.21.0
or
npm install -g npm#latest
This has been discussed on github
TL;DR;
It has been fixed in npm v7.17.0 and newer. I managed to upgrade from 7.10.0 to 7.21.0 and avoid this error entirely (and not dealing with agentkeepalive) by upgrading first to 7.17.0 and then to 7.21.0.
I do not know how, but this one worked for me:
$ npm --version
7.8.0
$ sudo npm uninstall -g npm
removed 252 packages, and audited 1 package in 586ms
found 0 vulnerabilities
$ sudo npm install -g npm
added 1 package, and audited 206 packages in 1s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
$ npm --version
8.17.0
Posting it as the accepted answer has not helped.

Npm always showing me npm ERR! when I try to install anything

Please I need your help whenever I try to install anything with npm I always get errors please help me.
Update
From what read from the docs you should install the #ionic/cli
$ npm install -g #ionic/cli
From the docs:
If there was a previous installation of the Ionic CLI, it will need to be uninstalled due to a change in package name.
$ npm uninstall -g ionic
$ npm install -g #ionic/cli
You may want to add debug info while installing e.g.:
$ npm install -dd -g #ionic/cli
From your screenshot not sure if there is an error with your GIT config, or permissions to install the ionic cli globally on your machine...
Outdated
There should not be a space between ionic and #4, you should run e.g.:
npm install -g ionic#4
You can try with command like this npm install -g ionic#{{version}}.
In the place of version you should put your prefered version.

$npm install -g npm#latest Wont work properly

I was trying to upgrade npm version, so updated node to v10.1.0 then did
npm install -g npm#latest
but still remain version of v5.6.0 after I checked with
npm -v
5.6.0
Can you help me to upgrade this to 6.1.0 or any latest version of npm.
Thank you in advance to all who help me on this question...
enter image description here
Are you using Linux/Unix or Windows?
It works to me.
If Linux based you need to sudo npm install -g npm#latest (sudo)

Unable to npm install or start with electron-quick-start

I am using the version of node that is stated on electron's site, which is 7.4.0 and I'm using NPM version 4.0.5 (Windows).
The problem I'm having is with the npm install command in the cloned electron-quick-start folder. I have tried using the command with --save-devand -g but they don't do anything to help.
Upon using just npm install;
fetchMetadeta: still install loadAllDepsIntoIdealTree
With the above stated arguments (output);
--electron-quick-start#1.0.0
Then npm start after the above output;
Pastebin
Any help would be greatly appreciated, thanks.
You must get npm install to work before you can start the app
You could try the following
npm cache clean
npm install This will cache clean of npm
npm install -g yarn
yarn install This will install yarn (This will probably work but it might not be what you're looking for). Yarn is an alternative to npm
npm -g install npm
npm install This will reinstall npm
And I would look into nvm and nvm-windows
And if none of those work I would look at
this issuse on github
And if that doesn't work I would just look at google

Resources