2

So this is a very weird one. Let me start by saying that things used to work fine.

I installed Node a few days ago and once complete I opened a command prompt (On Windows 10), I entered node --version and it returned the current installed version.

I have since needed to have two different versions of Node that I can switch between. Enter our hero NVM. So I installed NVM, I set the nvm install path to C:\nvm and ran the commands to install the different versions of Node I require.

Using the nvm command nvm use X.XX.XX, replacing the X's with the version number, appears to work as it creates a symlink and points to the correct files via the link. Meaning if I manually go to the symlink and click it, I am taken to the Node installation folder, so I know the symlink is working.

Ignoring the symlink for now if I open command prompt from the node install location c:\nvm\v16.0.0 for example I can run node --version and it will return the version correctly.

  • Note: I did not add the .exe on the end of the call to node
C:\nvm\v16.0.0>node --version
v16.0.0

This is where things get a bit weird. If I update the environment variable PATH to have a entry for c:\nvm\16.0.0 and then just run node --version I get the following error.

C:\>node --version
The system cannot find the path specified

What is confusing me is that if I just add the.exe on then everything works fine???

C:\>node.exe --version
v16.0.0

I have checked that .exe is on the PATHEXT environment variable.

enter image description here

Running other exe's work fine. I can type notepad in the command prompt and it opens a new instance just fine.

Im really lost for ideas here. I have uninstalled, reinstalled, rebooted, shutdown, removed all Environment variables, added all Environment variables, created my own EXE's etc. etc. Everything works except for Node needing to be called with its extension before it will execute and yes.... I did check there is only one file called node and its not getting confused between an exe and a bat file

Folder structure

Would really apricate any help on this one guys. Thanks!

Io-oI
  • 9,237

1 Answers1

1

I think I inadvertently found the answer. Running where node gave me the follwing output.

C:\Users\jacquesr>where node 
C:\Users\jacquesr\AppData\Roaming\npm\node   
C:\Users\jacquesr\AppData\Roaming\npm\node.cmd   
C:\Program Files\nodejs\node.exe  

This then got me thinking.. Maybe it doesnt know which version to use. the .cmd or the .exe.

So what I did was go move the references of anything to node in that directory into a new folder called old node Old node Then ran where node again ... Looking better

C:\Users\jacquesr>where node
C:\Program Files\nodejs\node.exe

And finally running node --version

C:\Users\jacquesr>node --version
v16.0.0

So testing it swaps the version using NVM and it does.

C:\WINDOWS\system32>node --version
v16.0.0

C:\WINDOWS\system32>nvm list

 21.1.0
 16.20.0
  • 16.0.0 (Currently using 64-bit executable)

C:\WINDOWS\system32>nvm use 21.1.0 Now using node v21.1.0 (64-bit)

C:\WINDOWS\system32>nvm list

  • 21.1.0 (Currently using 64-bit executable) 16.20.0 16.0.0

C:\WINDOWS\system32>node --version v21.1.0

Thanks for taking time to look at this if you did... I thought I would share how I found the issue so someone else could save some time.

Io-oI
  • 9,237