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!

5
  • please do not post screenshots of text ... copy the text and paste it into the post ... format it as code using the {} button
    – jsotola
    Commented Oct 26, 2023 at 6:48
  • Don't see why I would need to type out console logs but ok thanks for the advice Commented Oct 26, 2023 at 9:38
  • why would you type anything? ... just copy and paste ... some people with vision problems cannot view the pictures, but can use a screen reader to read the text
    – jsotola
    Commented Oct 26, 2023 at 14:37
  • Sure, I get that, thanks @jsotola. Just not sure how I would show the folder and environment variable contents easily. If you feel strongly about it, please feel free to edit the question. Commented Oct 26, 2023 at 15:00
  • the folder can be obtained by running dir in s cmd window ... the content of the environment dialog box can be copied and pasted .... format everything as "code" by appending ``` on a separate line before and after the text
    – jsotola
    Commented Oct 26, 2023 at 15:15

1 Answer 1

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.

2
  • "...could save some time", especially replacing image containing text (invisible in searches) with visibly explicit and "searchable" text!
    – Io-oI
    Commented Oct 27, 2023 at 2:02
  • Sure thanks for the comment @lo-ol just make sure you play by your own rules. superuser.com/questions/1544449/… and when you add images make sure to add an image description. Commented Oct 31, 2023 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .