How to upgrade NPM from 1.x to 2.x? - node.js

I'm running windows 7 and when I installed node.js, it came with NPM 1.4.3. I need NPM 2.0.2 so I ran the following;
C:\proj>npm install -g npm#2.0.2
npm http GET http://localhost:8000/nexus/content/groups/npm-all/npm/2.0.2
npm http 200 http://localhost:8000/nexus/content/groups/npm-all/npm/2.0.2
npm http GET http://localhost:8000/nexus/content/groups/npm-all/npm/-/npm-2.0.2.tgz
npm http 200 http://localhost:8000/nexus/content/groups/npm-all/npm/-/npm-2.0.2.tgz
C:\Users\pgreen\AppData\Roaming\npm\npm -> C:\Users\pgreen\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm#2.0.2 C:\Users\pgreen\AppData\Roaming\npm\node_modules\npm
The output does show that I'm using a local nexus plugin to do NPM Repository proxy, but I have no reason to suspect that is causing any problems.
After the install I see:
C:\proj>npm --version
1.4.3
So what am I missing to make npm version 2.0.2 available on the command line?

I just needed to RTFM:
Upgrading on Windows
By default, npm is installed alongside node in C:\Program Files
(x86)\nodejs. npm's globally installed packages (including,
potentially, npm itself) are stored separately in a user-specific
directory (which is currently
C:\Users\\AppData\Roaming\npm). Because the installer puts
C:\Program Files (x86)\nodejs before
C:\Users\\AppData\Roaming\npm on your PATH, it will always
use version of npm installed with node instead of the version of npm
you installed using npm -g install npm#. To get around this,
you can do one of the following:
Option 1: edit your Windows installation's PATH to put C:\Users\<username>\AppData\Roaming\npm before C:\Program Files
(x86)\nodejs. Remember that you'll need to restart cmd.exe (and
potentially restart Windows) when you make changes to PATH or how npm
is installed.
Option 2: remove both of
C:\Program Files (x86)\nodejs\npm
C:\Program Files (x86)\nodejs\npm.cmd
Option 3: navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g:
npm install npm
If you installed npm with the node.js installer, after doing one of
the previous steps go into C:\Program Files\nodejs\node_modules\npm
and copy the file named npmrc in the new npm folder, which should be
C:\Users\\AppData\Roaming\npm\node_modules\npm. This will
tell the new npm where the global installed packages are. See the
point below for more details.
(See also the point below if you're running Windows 7 and don't have
the directory C:\Users\\AppData\Roaming\npm.)

Related

npm does not support Node.js v12.18.3

Can see it's been asked a dozen times but none of the solutions I've found have worked for me so far.
I've installed the latest version of Node.js (12.18.3) on my Windows 10 PC and I'm trying to install a package using npm. When I input npm -v it comes back with 5.6.0, which to me looks out of date - but when I try and install a package or update npm, I get the following error every time:
npm WARN npm npm does not support Node.js v12.18.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
I've tried uninstalling Node.js completely, deleting all node_modules folders and restarting my computer after a fresh install, but it's the same thing each time. I've also tried using npm install -g npm and npm install npm#latest -g but again, I get the same error.
Any solutions here?
I found the work-around !
First you need to open your cmd line, and use " npm install -g npm#latest "
you'll get the error like this
C:\Users\KimeruLenovo>npm install -g npm#latest
npm WARN npm npm does not support Node.js v14.7.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function npm ERR! A complete log of this
run can be found in: npm ERR!
C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log
Go to the path where you can find the debug log( this file is found in your npm-cache folder)
C:\Users\KimeruLenovo\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node .
once deleted go back to your comand line and re-use the command
" npm install -g npm#latest "
This should do the trick :)
I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3.
The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": https://nodejs.org/en/download/).
This Github issue led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to C:\Users\{User}\AppData\Roaming and delete the npm and npm-chache folder and finally install node again (using the installer).
The problem on my end was arising because I was using NVM yet I had already previously installed NPM independently.
All I did to solve the issue was delete the npm and npm-cache folder located here:
C:\Users\your-username\AppData\Roaming. No need of doing a fresh npm install (just leave that to NVM)
I had the same problem. Delete node and npm cache in AppData folder inside C: drive and install recommended version on another drive.
Go to the path where you can find the debug log (this file is found in your npm-cache folder) C:\Users\yourname\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node. Once deleted go back to your command line and re-use the command " npm install -g npm#latest "
I had same issue.
I tried to install node with choco install -y nodejs.install.
then, npm i works fine.
(before that, nodist was uninstalled)
I used nodist to install node. it may be the cause I think.
I have the same problem even after reinstalling Visual Studio. Cleared caching, and the weird thing, the Node.Js which is installed is the lastest (12.18.3)
So far i've found the node modules of the npm package, in the troubleshooting file they were accuring this solution
"
You can check your npm version by running npm -v.
Steps to Fix
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.)
You can upgrade to the latest version of npm using:
npm install -g npm#latest
Or upgrade to the most recent LTS release:
npm install -g npm#lts
Upgrading on Windows
We have a detailed guide for upgrading on windows on our wiki.
Proxy and Networking Issues
npm might not be able to connect to the registry for various reasons. Perhaps your machine is behind a firewall that needs to be opened, or you require a corporate proxy to access the npm registry. This issue can manifest in a wide number of different ways. Usually, strange network errors are an instance of this specific problem.
Sometimes, users may have install failures due to Git/Github access issues. Git/GitHub access is separate from npm registry access. For users in some locations (India in particular), problems installing packages may be due to connectivity problems reaching GitHub and not the npm registry.
If you believe your network is configured and working correctly, and you're still having problems installing, please let the registry team know you're having trouble.
Steps to Fix
Make sure you have a working internet connection. Can you reach https://registry.npmjs.org? Can you reach other sites? If other sites are unreachable, this is not a problem with npm.
Check http://status.npmjs.org/ for any potential current service outages.
If your company has a process for domain whitelisting for developers, make sure https://registry.npmjs.org is a whitelisted domain.
If you're in China, consider using https://npm.taobao.org/ as a registry, which sits behind the Firewall.
On Windows, npm does not access proxies configured at the system level, so you need to configure them manually in order for npm to access them. Make sure you have added the appropriate proxy configuration to .npmrc.
If you already have a proxy configured, it might be configured incorrectly or use the wrong credentials. Verify your credentials, test the specific credentials with a separate application.
The proxy itself, on the server, might also have a configuration error. In this case, you'll need to work with your system administrator to verify that the proxy, and HTTPS, are configured correctly. You may test it by running regular HTTPS requests.
"
I'll try to work on it and keep you informed if i'm able to solve this problem
Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm#latest "
This should do the trick :)
As mentioned earlier, is that I deleted these folders before installing the new version and also worked.
Start by uninstalling the node js by running npm uninstall -g npm, you will fall back to the previous version of Node.js
Just install what is required from the official site of Node.js https://nodejs.org/en/
No SO version or command lines required
If none of these solutions work which happened to me just go to https://nodejs.org/en/ and download the recommended version manually super fast!
Use n.
I am so glad discovered this package.
if npm installed;
npm install -g n
n lts
for other ways or more details;
https://www.npmjs.com/package/n
My specific case required that I use node 12.14 and I was getting this error.I tried installing the npm version but still was getting this issue
I was using NVM, so I uninstalled all other versions of node using
nvm uninstall 18 And like this all other versions
Before uninstalling the last version, I was getting some error so I ran
nvm deactivate
After which I uninstalled the last remaining node version too
I uninstalled the npm after that, and installed just the node version I needed using NVM
nvm install 12.14
and it installed the required npm too, with it my problem was solved. Hope this would be of use to someone

Unable to upgrade to latest version of npm after installing recent Node version [duplicate]

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
I tried this:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
...but it didn't work.
How do I do this on Windows?
Note: The question is specifically asking how to upgrade npm, not Node.js. If you want to update Node.js over a CLI on windows, I recommend running winget upgrade -q NodeJS or use chocolatey for that.
What method should I choose to update NPM?
Node.js v16 or higher?
npm install -g npm
Node.js v14 or below?
Consider updating to latest LTS release of Node.js
npm-windows-upgrade
Upgrade with npm-windows-upgrade
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Note: if you run the Node.js installer, it will replace the Node.js version.
Upgrades npm in-place, where Node.js installed it.
Does not modify the default path.
Does not change the default global package location.
Allows easy upgrades and downgrades and to install a specific version.
A list of versions matched between NPM and Node.js (https://nodejs.org/en/download/releases/) - but you will need to download the Node.js installer and run that to update Node.js (https://nodejs.org/en/)
Upgrade with npm
npm install -g npm
Note: some users still report issues updating npm with npm, but I haven't had that experience with v16+.
Download and run the latest MSI. The MSI will update your installed node and npm.
To update NPM, this worked for me:
Navigate in your shell to your node installation directory, eg C:\Program Files (x86)\nodejs
run npm install npm (no -g option)
Like some people, I needed to combine multiple answers, and I also needed to set a proxy.
This should work for anyone. I have zero desire to run an EXE file or MSI file .. uninstall/ reinstall, or manually delete files and folders. That is so 1999 :P
Run this to update NPM:
Run PowerShell as administrator
npm i -g npm // This works
I am not thinking this code actually upgrades your npm version below
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
(courtesy of "Robert" answer)
Run this to update Node.js:
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files (x86)\nodejs\node.exe' (courtesy of BrunoLM answer)
If you get `wget : Could not find a part of the path .... "**, see below ...scroll down. Reading Web Response... It's at least punching through the firewall /proxy (if you have one or have already ran the code get through ...
Otherwise
You might need to set your proxy
npm config set proxy "http://proxy.yourcorp.com:811" (yes, use quotes)
2 possible errors
It cannot find path of the path solution "where.exe node" (courtesy of Lonnie Best Answer)
E.g. if Node.js is NOT living in "Program Files (x86)" perhaps with where.exe, it is living in 'C:\Program Files\nodejs\node.exe'.
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'
Now perhaps it tries to upgrade but you get another error, "node.exe is being used by another process."
Close /shutdown other consoles .. command prompts and PowerShell windows, etc. Even if you're using npm in a command prompt, close it.
npm -v (3.10.8)
node -v ( v6.6.0)
DONE. I'm at the version that I want.
You can update your npm to the latest stable version with the following command:
npm install npm#latest -g
Use PowerShell to run it. This command doesn't need windows administrator privileges and you can verify the result with npm -v
You can use Chocolatey which is a package manager for windows (like apt-get for Debian Linux).
Install fresh (you might need to uninstall previously installed versions)
> choco install nodejs
Update to the latest version
> choco update nodejs
and for npm
> choco update npm
The previous answers will work installing a new version of Node.js (probably the best option), but if you have a dependency on a specific Node.js version then the following will work: "npm install npm -g". Verify by running npm -v before and after the command.
This works fine for me to update npm on Windows 7 x64:
Windows start
All Programs
Node.js
Node.js command prompt (alternative click)
Run as administrator
$ npm -g install npm
remove C:\Program Files\nodejs\npm.cmd the new npm will be at C:\Users\username\appdata\roaming\npm\npm.cmd
Hope this helps.
Open PowerShell as administrator.
To install a first time you can use this small script to download the latest msi and run it
$nodeLatest=((curl https://nodejs.org/download/release/latest/).Content | findstr x64.msi) -replace "<(.*?)>", "" -replace "\s+.+", "";
wget "https://nodejs.org/download/release/latest/$nodeLatest" -OutFile (join-path $env:TEMP node.msi); Start-Process (join-path $env:TEMP node.msi)
On future upgrades you can download just node.exe and update npm with
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'
npm i -g npm
You should now have the latest node and npm.
I went a little further and decided to implement a nvm for Windows.
https://github.com/brunolm/nvm
Install-Module -Name power-nvm
nvm install latest
nvm default latest
1. Installing latest npm version
npm install –g npm#latest
(You can type "npm –version" to check that)
2. Installing Node
a. Install node new version via following URL: https://nodejs.org/en/download/current/
Follow the default choices
b. Remove C:\Users\\AppData\Roaming\NPM
c. Remove C:\Users\\AppData\Roaming\npm-cache
Optionally:
d. (Delete node_modules folder in your current project folder)
e. npm cache verify
f. npm install
Use Upgrade npm on Windows
This is the official document for a user to upgrade npm on Windows!
Here is my screenshot!
For what it's worth, I had to combine several answers...
Uninstall Node.js in control panel Add/remove programs.
Delete directories, both C:\Program Files (x86)\nodejs\ and C:\Program Files\nodejs\ if they exist.
Install the latest version, http://nodejs.org/download/
How to Update Node.js:
Uninstall Node.js. Click the Start menu, type "Change or Remove a Program", click on the item shown, find Node.js in the list and uninstall it.
Delete directories, both C:\Program Files (x86)\nodejs\ and C:\Program Files\nodejs\ if they exist.
Install the latest, https://nodejs.org/en/download
The uninstall/delete/install seems unnecessary, but it often is and this will save your time.
These instructions come from Microsoft.
How to Update NPM:
https://www.npmjs.com/package/npm-windows-upgrade
This is the official documentation for upgrading npm on windows.
All was tested and working on Windows 10 (2017).
this is best tool to maintain version of NODE.Js i NVM
Node Version Manager (nvm) for Windows
but for Windows, with an installer. Download Now! This has always been a node version manager, not an io.js manager, so there is no back-support for io.js. However, node 4+ is supported.
For me, after totally uninstalling node 10.29, and then installing node 4.2.2, there remained a 10.29 node.exe file in my c:\windows folder.
I found this by using the following command:
where.exe node
The command returned:
C:\Windows\node.exe
C:\Program Files\nodejs\node.exe
So even though I had successfully installed version 4.2.2 via the msi executable, the command node -v would continue to report I was running version 10.29.
I resolved the problem by deleting this file:
C:\Windows\node.exe
Thereafter, node -v reported the upgraded version instead of the unwanted remnants of the prior version.
For NodeJS
Download required node version msi from here and install
for Npm
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
This works fine for me
Run Command Prompt as Administrator
Navigate to the folder containing nodejs (eg. C:\Program Files\nodejs)
Run Powershell -ExecutionPolicy Unrestricted
Run npm-windows-upgrade
This will show list of versions available to install. Just select your desired version by moving up/down key & Press Enter.
This'll update your npm
To check the current version of npm
Run npm --version
Command Prompt Screenshot
I was also facing similar issues. I followed below mentioned steps and it worked for me:
go to Windows > Start > Node.js
right click on Node.js command prompt
click on Run as administrator
ping registry.npmjs.org
npm view npm version
cd %ProgramFiles%\nodejs
npm install npm#latest
and npm updated successfully. Earlier I was trying for CMD and that was throwing error. may be some path issue that got resolved by running NodeJs Command Prompt. hope it'll work for you. try this.
OK guys, I read (tried on Windows) all the previous stuff and all of these answers have their own disadvantages.
For the best way to update Node.js (at least for me), go to https://nodejs.org/en/
Then download the last version and install it in same folder you installed the previous version in - 1 min and it's done. You don't need to remove any old files.
Then update npm typing in cmd: npm install --save latest-version
To install the updates, just download the installer from the Nodejs.org site and run it again. The new version of Node.js and NPM will replace the older versions.
The easiest way I found so far to update Node.js is using Chocolatey.
Use Chocolatey to install or update the latest version of Node.js on Windows:
Step 1: First, ensure that you already have Chocolatey installed. If not, use an administrative shell to install chocolatey through cmd.exe or PowerShell.exe. For more information, visit: https://chocolatey.org/docs/installation
Step 2: Install with cmd.exe. Run the following command:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
To install with PowerShell.exe, visit: https://chocolatey.org/docs/installation
Step 3: Install or Update with following commands on cmd.exe (on administrative mode)
To Install Node.js: cinst nodejs.install
To Update Node.js: cup nodejs.install
follow these steps for window 10 or window 8
press WIN + R and type cmd and enter
npm i -g npm#next
npm i -g npm#next OR npm i -g node#{version}
Remove environment path C:\Program Files\nodejs from envrionment variable PATH.
type refreshenv in cmd
Now you will have your new version which you installed.
Note: If you don't remove path. You will see the previous version of node.
PowerShell does not execute npm directly, so I suggest using
.\npm install -g npm-windows-upgrade
.\npm-windows-upgrade
And it failed with:
You wanted to install npm 6.1.0, but the installed version is 3.10.10.
A common reason is an attempted "npm install npm" or "npm upgrade npm". As of today, the only solution is to completely uninstall and then reinstall Node.js. For a small tutorial, please see http://aka.ms/fix-npm-upgrade (dead link).
Please consider reporting your trouble to npm-windows-upgrade.
I followed josh3737 and installed the latest MSI from the Node.js homepage.
But I had the additional problem that I still had the old version of Node.js and npm on the command line. The problem was caused by the new installation, and that it was installed into
C:\Program Files (x86)\nodejs\
instead of the previous installation in
C:\Program Files\nodejs\
The new installation added the new directory into my path variable after the old one. So the old installation was still the active one in the path. After removing C:\Program Files\nodejs\ from system path and C:\Users\...\AppData\Roaming\npm from user path and restarting the command line the new installation was active.
Maybe the least path was a local problem that has nothing to do with the new installation. I had two links to AppData\Roaming\npm in it. And maybe this can also be fixed by first uninstalling Node.js and installing the new version afterwards.
You can use these commands:
npm cache clean
npm update -g [package....]
If you are upgrading from a previous version of node, then you will want to update all existing global packages.
You can also specify the package name to be updated.
This might help someone. Neither "npm-windows-upgrade" nor the installer alone did it for me. Powershell was still using an older version of node and npm.
So this is what I did (worked for me):
1. Download the latest installer from nodejs.org. Install node. It will update your node; everywhere (Powershell, cmd etc.).
2. Install the npm-windows-upgrade package (npm install -g npm-windows-upgrade) and run npm-windows-upgrade.
I didn't uninstall anything and didn't set any paths.
In my case, I discovered that I had two copies of Node.js installed. One under "C:\Program Files\nodejs" and another under "C:\Program Files (x86)\nodejs".
This is what worked for me.
Open a local folder other than the one in which nodejs is installed.
Install npm in that folder with command npm install npm
Navigate to the folder containing node js. (C:\Program Files\nodejs\node_modules)
Delete the npm folder and replace it with the npm and bin folders in the local folder.
Run npm -v. Now you would get updated version for npm.
Note: I tried installing npm directly in "C:\Program Files\nodejs\node_modules" but it created errors.
Start
Search for windows powershell
Right click and run as administrator
Type: where.exe node (returns the path of node.exe in your system. Copy this)
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'PATH-OF-NODE.EXE_WHICH_YOU_COPIED_JUST_NOW'
To check if it has worked, go to your Git bash/Normal command prompt and type: node -v
Here you can find the current version of node: https://nodejs.org/en/blog/release/

npm located in two different directories on Windows 10

I just had a trouble to upgrade my npm version from 5.0.0 to 6.4.1 on Windows 10.
What i did was just downloading NodeJS (latest) installer, i.e. 8.12.0 (it includes npm 6.4.1). It was successfully installed, however when i did npm -v it still on version 5.0.0, so it only updated the node part only.
Then i follow this instruction (link), basically it uses npm package called npm-windows-upgrade, at first try it threw a lot of error.
Basically i have to do several cycles of NodeJS uninstall, NodeJS reinstall, and executing npm-windows-upgrade, after few times it finally succeeded (luck), now my npm is at 6.4.1. However when i run where npm on terminal it listed two locations of my npm files:
C:\WINDOWS\system32>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\XXX\AppData\Roaming\npm\npm
C:\Users\XXX\AppData\Roaming\npm\npm.cmd
and this is kind of strange, it should only listing one location, i.e. C:\Program Files\nodejs\.. but apparently i have npm too on AppData\Roaming directory, why is this happening? should i delete the second one?
PS - If i run where node, it listed only one location, i.e:
C:\WINDOWS\system32>where node
C:\Program Files\nodejs\node.exe
C:\Users\xxx\AppData\Roaming\npm is the location for node packages for the current user, while C:\Program Files\nodejs\ is the installation dir for all users.
See what C:\Users\XXX\AppData\Roaming\npm\npm.cmd -v returns. If it's the same as npm -v then you are fine.
You could run node without the installer, in this case C:\Program Files\nodejs\ would not be in the PATH (for System env variables), however all the global packages would be placed under C:\Users\XXX\AppData\Roaming\npm\. Since npm is a global package, it appers there.
TL;DR No action required.

Updating NPM with Nodist

I'm unable to update npm, and get it to use with Nodist.
Whenever I try to update npm with the command
npm install -g npm
the following message comes right after executing it:
(node:5304) fs: re-evaluating native module sources is not supported.
If you are using the graceful-fs module, please update it to a more recent version.
C:\Program Files (x86)\Nodist\v\nodev6.5.0\npm -> C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm\bin\npm-cli.js
npm#3.10.6 C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm
Doing an npm -v right after, gives me the previous version:
...> npm -v
2.14.10
However, if you noticed the last line in the message above, there is npm#3.10.6 which means it is somehow trying to install that version of npm.
I also followed instructions from this post for Ubuntu users and this for Windows users, but they seem to address issues with standalone NodeJS installations and NOT NodeJS + Nodist combo.
Meanwhile, I was wondering if Nodist itself enables us to update npm, or in other words, does it have any version management feature for npm as well, just as it does for node.
Thanks for any help in advance.
Additional Info
I am using Nodist v0.7.1 on Windows 7.
You can try nodist npm latest
Nodist manages npm versions as well as node versions.
Turns out that Nodist versions prior to v0.7.2 have an issue with getting npm set with Nodist correctly (refer the Nodist changelog).
Performing an npm install -g npm was in fact installing the latest version of npm under the v-x64 in Nodist's root installation folder - which is not where Nodist itself looks for npm installation.
Nodist looks for npm inside the \bin folder:
Solution
Add the bin folder's path to your PATH.
cd to the Nodist installation > bin directory with your terminal,
and then perform:
npm install npm
(not with -g flag of course).
Alternatively, if npm install doesn't work in this step, copy an already installed npm and paste it in the node_modules folder within the bin directory.
As a side note, remember to remove some values from your PATH which I suppose may cause conflicts with global package installations (i.e. with -g flag) with npm, before installing Nodist, which are as follows:
%appdata%\npm; OR C:\Users\username\AppData\Roaming\npm;
%ProgramFiles%\nodejs;
I used to have the same issue.
You should use the following command nodist npm 6.14.5, changing the version you need.
And you can see more option whith this command: nodist --help is where I found the answer:
see an example

Can't get last version of NPM working

I'm trying to update npm to latest version, since I'm using the 1.4.28.
Using:
npm update -g npm
I get the following output:
npm#1.3.26 C:\Users\ck\AppData\Roaming\npm\node_modules\npm-check-updates\node_modules\npm
npm#2.1.5 C:\Users\ck\AppData\Roaming\npm\node_modules\ember-cli\node_modules\npm
and then running
npm -v
I can see that I'm still using the 1.4.28; I can't understand the output I got after trying to update, since it is talking about 1.3.26 and 2.1.5, but I have installed 1.4.28??
I'm on windows and I've already tried to uninstall and reinstall node;
from this page:https://github.com/npm/npm/wiki/Troubleshooting
on windows:
Option 1:
edit your Windows installation's PATH to put C:\Users\<username>\AppDa\Roaming\npm before
C:\Program Files (x86)\nodejs. Remember that you'll need to restart cmd.exe (and potentially restart Windows) when you make changes to PATH or how npm is installed.
Option 2: remove both of before updating
C:\Program Files (x86)\nodejs\npm
C:\Program Files (x86)\nodejs\npm.cmd
Option 3: navigate to C:\Program Files (x86)\nodejs
with cmd.exe and then run the installation without -g:
npm install npm
on linux:
npm install -g npm#latest
In order to install the latest npm, you'll run:
npm install -g npm#latest
You'll also need to ensure that if you have multiple npm commands installed, you are using the latest (rather than the original npm installed with node).
Try this:
which -a npm
Based on your findings from the above command, you may need to adjust your PATH environment variable.
Finally able to update npm. A bit uncooperative guy whew! Tried to install / update nom first npm install -g nom#latest then npm install -g npm#latest on admin level console / windows command.
From 1.4.28 to 2.1.7
Weird but hey it works for me!
On Windows, you may need to check both your user path and system path. If C:\Program Files\nodejs\; appears in system path and C:\Users\<username>\AppData\Roaming\npm, then npm will refer to the version in C:\Program Files\nodejs\;. This was the problem for me, and was resolved by putting C:\Program Files\nodejs\; at the end of the user path and removing it from the system path. Don't forget to restart the terminal after changing the path. Though useful in helping me to find the problem, none of baaroz's solutions worked in my case.
I deleted this folder C:\Users<username>\AppDa\Roaming\npm and C:\Users<username>\AppDa\Roaming\npm-cache and the did the node.js install and was able to have the updated version of npm

Resources