NVM for Windows not working? - windows

I just installed NVM for Windows, but it doesn't seem to be working:
Any ideas?

First examine your actual "C:\Program Files\nodejs" directory. Most of us already have a "nodejs" directory from a prior install, before we decided (or were told) to install nvm.
In the end, this "C:\Program Files\nodejs" directory will actually be a shortcut to where nvm manages the versions it installs (see C:\Users\xxx\AppData\Roaming\nvm). It seems that nvm is simply switching the shortcut, when we call "nvm use ...".
Ok, so here is what I did to fix the situation where "nvm use ..." was not taking effect.
Delete/remove/uninstall the version of node in your "C:\Program Files\nodejs" directory. To the point where there is no more "nodejs" directory at all.
Delete the existence of nvm (C:\Users\xxx\AppData\Roaming\nvm), basically, manually delete the nvm dir.
Download your desired version of nvm (https://github.com/coreybutler/nvm-windows/releases)
Open a CMD prompt (run as administrator), and install the downloaded version of nvm, nvm-setup.exe, from within this CMD command prompt.
From within the admin level command prompt, run "nvm install 7.2.1", or whatever node version you want to install. Probably you will be installing multiple versions, so repeat as needed.
Now do the usual "nvm use ...", "nvm list", etc...
I dont know if this is the best way, but it worked for me...

Having the same issue after installing latest node with nvm. node command was not recognized in console. Closing and opening command windows did not work. checked nvm arch to which the response is
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
Had to set the node again with arch setting
C:\WINDOWS\system32> nvm use 7.4.0 x64
Now using node v7.4.0 (64-bit)
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: 64-bit.
C:\WINDOWS\system32> nvm list
* 7.4.0 (Currently using 64-bit executable)
4.5.0
C:\WINDOWS\system32> node -v
v7.4.0

Rename "C:\Program Files\nodejs" to "C:\Program Files\nodejsx"
nvm use x.x.x
This worked for me. Maybe it will work for you too.

Most likely what is happening is that the system %PATH% is being updated outside of the command prompt instance. Only opening a new command prompt will pick up these new external changes.

I had the same problem in Windows 10, and the solution for me was in #pleverett answer in https://github.com/coreybutler/nvm-windows/issues/191
Symptoms: no bit architecture and no default version
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
C:\WINDOWS\system32> nvm list
8.9.4
6.13.0
Solution:
After uninstalling node, make sure the directory where node was originally installed has been removed and not just empty. For Windows 7 ad 10, 64-bit, the default is "C:\Program Files\nodejs".
If the "nodejs" directory still exists then the "nvm use" command can't make the symbolic link to the node version under nvm's control.
I had the same problem until I manually deleted the "nodejs" directory.

Make sure you delete all old nodejs.
Install nvm
Install node
Open new terminal prompt
run 'nvm on'
run 'nvm list'
run 'node --version'

In my case I was using git bash -- switching to cmd.exe worked.
More suggestions at: https://github.com/coreybutler/nvm-windows/issues/58

I had to manually set the PATH variable in System environment variables of Windows to fix this issue.
Here are the steps:
Before installing nvm, delete the following path:
C:\Program Files\nodejs
C:\Program Files (x86)\nodejs
after installing nvm execute:
nvm use
After the use command you can find a shortcut 'C:\Program Files\nodejs' is created by
nvm in this path.
The problem i found was the path 'C:\Program Files\nodejs' was not set in the windows system evnironment PATH variable.
i appended 'C:\Program Files\nodejs' to the %PATH% variable to fix this issue.

I had to open the installer with admin permissions.
Then I opened the command line and I was able to install and use nvm properly.
nvm install 10.0.0
nvm use 10.0.0
node --version
// version 10 is used.

I installed nvm-windows in order to get multiple versions of node to work. After installation I got the error that most folks complained about which is that it was unable to find the file settings.txt. There are two things required to get nvm-win to work and the installer only does the first of these two. So after installation just check that points 1 and 2 are covered and you should be good. There is no need to uninstall prior versions of node as far as i can tell.
update the system path variable to the directory where you installed nvm and where the nvm.exe is located. ex. c:\nvm
add a new variable NVM_HOME to the system variables.
open a new command window after verifying 1 and 2.
Problem 2 switching between versions
Switching between versions gives a success message but it will not actually work properly unless you manually update the windows system path variable to point to the location that you installed your target version in, for example C:\Users\adamm>nvm list
10.15.1
* 6.4.0 (Currently using 64-bit executable)
So it appears to work but if you type node -v it will show whichever version is currently in your path variable until you edit the path variable to use 6.4.0

I was getting the same issue. I installed node using nvm but 'node' and 'npm' were not recognized by the system.
So, what I did was I didn't delete any folders or anything I just ran the command prompt as administrator and did the nvm install 'desired-version' and everything started to work fine.

I understand this is an old question.
However, what fixed it for me isn't in any of the answers above, which is why I decided to answer this in case new persons find this page and none of the above answer works for them...
All I had to do was run nvm on which creates the symlink (supposedly, nvm use <version> is supposed to work, but it wasn't), turning on nvm before using a version worked for me.
Steps:
nvm install <version> -> Installs a node and npm of <version>
nvm on -> Turns on nvm, and creates the nodejs symlink needed
nvm use <version> -> To use a specific version
node -v -> prints out version of node
npm -v -> prints out version of npm
Hopefully, it fixes your issue too.

For me,
nvm list
Then I remove v8.9.4 folder out of nvm.
After that:
nvm list
Then, I move v8.9.4 back.

For me it was I installed node using nvm on a non-admin cmd.
Running cmd as admin worked for me.
open a new cmd with admin rights then run this command.
run 'nvm on'

Why isn't node version changing with nvm for windows even when nvm on ?
when nodejs is already installed, the enviroment variable NVM_SYMLINK which created when nvm for windows is installed will point to C:\Program Files\nodejs(which is default)
what is the expected behavior ?
when we run nvm on and then nvm use x.x.x, we should able to switch to the desired node version without any hassle.
how to fix ?
uninstall the nodejs using uninstall/remove programs from control panel and delete C:\Program Files\nodejs if exists
check (once) if NVM_SYMLINK in environment variables is changing automatically when running nvm use x.x.x
if not changing automatically then uninstall and reinstall nvm for windows (remove any other node remains)
Note: I am able to switch to the desired versions of node by changing the user environment variable NVM_SYMLINKto C:\Users\Charlie\AppData\Roaming\nvm\vx.x.x without uninstalling the node.

At my work we are assigned a user account and an administrative account which we use to install and manage software for our machines. NVM was installed under this admin account and therefore, none of the answers above worked for me.
I had to manually add %NVM_HOME% and %NVM_SYMLINK% to my user account's path before I could get node --version to display anything.
So if you have to deal with a regular account and an administrative account then the following will work for you:
Install NVM (which will have to be installed using your admin account)
Manually added %NVM_HOME% and %NVM_SYMLINK% to your user account's path (if you check your admin account's path you'll see these 2 were added there during the NVM installation)
nvm install latest
nvm on
nvm use x.x.x
Restart computer so your IDE recognizes the changes
$Profit$

To me the issue was that I had problems with the download, I had to download the zip file manually and place its contents int he nvm folder C:\Users\xxx\AppData\Roaming\nvm

Try nvm run node --version
You can also get the path to the executable to where it was installed:
nvm which 5.0

Something that fixed it for me: Comb through your PATH variable. I had multiple links to different node versions and it worked perfectly after I cleaned up all of them, leaving NVM's variables in tact.
If executing where node comes back with more than one path this is likely your issue.

This work fine for me:
In the C:\Program Files\ folder use cmd to run mklink /D /J nodejs C:\Users\[user]\AppData\Roaming\nvm[node version]
Please note that cmd run in administrator mode.
Detail here: https://github.com/coreybutler/nvm-windows/issues/321#issuecomment-407876718

For me, the issue was that I was using the nosetup way and downloaded the zip in my user Downloads folder. When I switched to setup installer, it worked for me.

You need Administrator access for installing node. Since you got into problem before knowing solution, follow below step.
Note down all installed node version(Optional)
"C:\Program Files\nodejs" (Optional but Recommended)
Delete "C:\Users\xxx\AppData\Roaming\nvm"
Reinstall nvm
Run cmd as Administrator
nvm install x.x.x

I had same issue. C:\Program Files\nodejs shortcut folder was present but was not pointing to anywhere.
I simply deleted the C:\Program Files\nodejs symlink and executed the below command
nvm use 0.10.36
This created new C:\Program Files\nodejs symlink and it worked properly.

Aside to all other solutions described here, there is another issue with nvm. Nvm switches between version of Node.js. Node.js builds are grabbed from Node.js repository.
If you can switch between some versions, but not all, and specifically you can not switch to versions you just grabbed, that answer is for you.
The situation happens because Node.js rebuilds old builds. For example, there is a build 10.14.1 you can grab from their repository, and that nvm grabs. But it is not a build from the past. Node.js rebuilds old builds too regularly.
Unfortunately, they don't take care about backwards compatibility. It means that if your operating system is not supported by Node.js, not only the latest build won't be supported. All old builds will also be broken for your system.
Currently, Node.js supports Windows 10+. It means that all old Node.js packages has been rebuilt in a way, that break them for Windows 8.x and Windows 7.
What is astonishing, there is no place to grab the old, working builds. Once they rebuild old releases, they break backwards compatibility.
As for now, there is no solution for that. The only thing you can do, is to grab releases while they are supported on your system. For example now, you can grab versions for Windows 10, because when they announce Windows 11 is a minimum requirement, all Node.js builds will break on Windows 10.
From the nvm perspective, you can see any kind of errors during the installation. During switching the visible result is that you can not switch between versions. The version you choose is not the current one and not marked with an asterix in the npm list result.

For me there were 2 things I needed to do:
Run nvm install as administrator
Specify the exact version (major.minor.point) with nvm use
Steps:
Open Terminal as Administrator
Run nvm install 14
Run nvm use 14.20.0
Open Terminal as non-admin
Run node -v to verify it's using 14.20.0
If I tried nvm use 14 without minor or point version, it did not work, which differs from NVM on Mac. I also could not run nvm use in a non-admin terminal, it gave "Access is denied".

For me deleting npm and npm-cache folder from AppData works

For me running nvm install 14.0.0 from PowerShell with admin rights did the job.

You must delete your C:\Program Files\nodejs directory.
Check the version of the node available with nvm list.
If you have your version, run command nvm use x.x.x.
otherwise run nvm install x.x.x and run command nvm use x.x.x.

For me setting up environment path variable also didn't work. Finally I got the cause and it was incompatible node version, once I downgraded my node from 14 to version used in my frontend application i.e. v8.11.3, it worked for me.

Related

How do I install Git for Windows software to a specific directory?

I have just downloaded the latest Git for Windows installer, v2.4. It appears to want to install to the standard Windows "Program files" (with-spaces-in-name) directory.
Since I have all my development code in a folder called (simply) "/bin" -- I want to see if there's a command line option or parameter to change the install directory.
In my case, these days I use a environment variable such as GIT_HOME for important software like git; so it would be useful if there was a way to apply that to things like git commands, etc once I have the program installed.
possibly related:
How do I change the directory in Git Bash with Git for Windows?
I also came across a few questions asking: "whereis git". That's answered above, however I take that as an indicator that others may want git somewhere else too.
To start the installer with a different installation path you can open a CMD terminal in the same directory as the installer executable and pass in an option parameter of /DIR="x:\dirname"
For instance, if you have version 2.17.0 for Windows 64bit and you want to install git to D:\git, you would run:
Git-2.17.0-64-bit.exe /DIR="D:\git"
The installer will launch as usual and you need to walk through the other options, but the install location will be the path specified.
Since I just ran into this problem because my SSD is filling up, I figured I'd share the solution I came to on Windows 11 with Git v. 2.37.2.
The best way I could figure was to uninstall Git, then in CMD Prompt use the suggested command from the Git website with an appended --location/ -l flag:
winget install --id Git.Git -e --source winget --location [drive:/directory]
where [drive:/directory] is your target for the install. Had no issues and verified it worked with a project.

Cannot reinstall Composer on WAMP server

I have uninstalled Composer using the Windows uninstaller (I'm on Windows 8) and now when I run the Composer installer I get:
Composer is already installed in the following directory:
C:\wamp\bin\php\php5.5.12
You must remove it first, if you want to continue this installation.
Since obviously Windows did not completely remove it can anybody with more skills than me give me a tip on how to fix?
Remove the path C:\wamp\bin\php\php5.5.12 from your Environment variable, named Path in the System properties.

Whats the best way to install nodejs in different location

By default nodejs is installed in /usr/local/bin/node but this location needs root access rights.
If I then install a global package like grunt-cli or a yeoman generator they also need root access rights. But I don't want to install all global packages with sudo.
So I tought why not install node and its global packages under something like opt/bin/node for example and give this location user access rights.
I used to download the installer from the nodejs website but with that I can't change location of the installation. So the question is:
How can I install nodejs in a differnt location than the default location on OSX and Windows?
Search engines are your friend.
Taken directly from the node docs:
On Windows
The http://nodejs.org/dist/latest/ directory contains executables of
the last version of Node.js engine (the engine only, i.e. without
npm):
32bit version: http://nodejs.org/dist/latest/node.exe
64bit version: http://nodejs.org/dist/latest/x64/node.exe
The http://nodejs.org/dist/npm/ directory contains the latest .zip
archive of npm (such as npm-1.1.16.zip when npm v1.1.16 was the
latest).
Manual installation steps:
Make a clean directory and add that directory to your system's PATH variable.
Download the latest node.exe to that directory.
Download the latest npm's .zip file and unpack its contents to the same directory.
Then, with the usual help of PATH, you'll be able to run scripts (node
scriptname.js) and install modules (npm install modulename) in any
directory.
...and just below that...
Installing on Mac
The http://nodejs.org/dist/latest/ directory contains the latest .pkg
package (such as node-v0.6.15.pkg when Node v0.6.15 was the latest).
we have discussed your issue with some unix guru´s.
in UNIX / MAC:
we believe the best way to install a node package "global" (non-project-specific respectively in your user environment) is to install node in folder
/opt/node or /home/user/.node and change the user-right, as you mentioned.
we believe its the wrong way, to change the /usr/ folder-rights or install global-packages with sudo.
in my case, i think the solution to change npm-config (mentioned in many other stackoverflow topics) did not changed anything, because node is still installed in /usr/bin.
still we belief, as a developer its more recommended to build such frequently updated applications like node by yourself instead of using the unix package manager. because mostly the resources ain't up to date.
I've had great success with nvm: https://github.com/creationix/nvm. It's a version manager for node, but one of the best parts of it (for me) is that it installs each version of node in your home directory. This means that your npm global install is also in this home directory. It's a Mac/Unix solution.
For Windows, though I've never tried it, there is the (similar) nvmw project: https://github.com/hakobera/nvmw.

git is not installed or not in the PATH

Windows, when I try to run npm install, it shows:
mean#1.0.0 postinstall E:\mean
node node_modules/grunt-cli/bin/grunt install
Running "bower:install" (bower) task
Fatal error : git is not installed or not in the PATH
npm ERR! weird error 1
npm ERR! not ok code 0
What is the problem? How to fix it?
The project git repository is https://github.com/linnovate/mean
Did you install Git correctly?
According to the Bower site, you need to make sure you check the option "Run Git from Windows Command Prompt".
I had this issue where Git was not found when I was trying to install Angular. I re-ran the installer for git and changed my setting and then it worked.
From the bower site:
http://bower.io/
while #vitocorleone is technically correct. If you have already installed, there is no need to reinstall. You just need to add it to your path. You will find yourself doing this for many of the tools for the mean stack so you should get used to doing it. You don't want to have to be in the folder that holds the executable to run it.
Control Panel --> System and Security --> System
click on Advanced System Settings on the left.
make sure you are on the advanced tab
click the Environment Variables button on the bottom
under system variables on the bottom find the Path variable
at the end of the line type (assuming this is where you installed it)
;C:\Program Files (x86)\git\cmd
click ok, ok, and ok to save
This essentially tells the OS.. if you don't find this executable in the folder I am typing in, look in Path to fide where it is.
Installing git and running npm install from git-bash worked for me. Make sure you are in the correct directory.
Install git and tortoise git for windows and make sure it is on your path, (the installer for Tortoise Git includes options for the command line tools and ensuring that it is on the path - select them).
You will need to close and re-open any existing command line sessions for the changes to take effect.
Then you should be able to run npm install successfully or move on to the next problem!
In my case the issue was not resolved because i did not restart my system. Please make sure you do restart your system.
If you installed GitHubDesktop then the path for git.exe will be ,
C:\Users\<'Username'>\AppData\Local\GitHubDesktop\app-1.1.1\resources\app\git\cmd
Add this path to the environment variables by following,
** (Note: \cmd at the end, not \cmd\git.exe).**
Navigate to the Environmental Variables Editor and find the Path variable in the “System Variables” section. Click Edit… and paste the URL of Git to the end. Save!
Now open a new cmd and type command git. If you are able to see the git usage then it's done.
Now you can execute your command to install your package.
ex: npm install native-base --save
Use Git CMD instead of using Win CMD.
I did install git and tried again and got the same error. But running 'npm install' in a new command prompt window worked for me. Restarting the machine is not required.
Go to Environmental Variables you will find this in Computer Properties->Advance system Setting->Environmental Variables -> Path
Add the path of your git installed int the system.
eg: "C:\Program Files\Git\cmd"
Save it.
Good to go now!!
The issue depends on the command prompt you are using. if you are using your Windows cmd, then it will be fine if you have installed git in your system (note that after installation it gets added to your system path). if you are running on an Anaconda terminal or any other, then you need to install git on your project environment from the terminal.
for anaconda, the problem gets solved by running:
conda install git

How can I update npm on Windows?

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/

Resources