coreybutler / nvm-windows

A node.js version management utility for Windows. Ironically written in Go.
MIT License
37.28k stars 3.32k forks source link

[Issue]: nvm use command does not select certain versions #1127

Closed jiaohanying closed 5 months ago

jiaohanying commented 5 months ago

What happened?

When using use command, versions below nodejs 17 cannot be selected. I tested node versions 20, 18, 17, 16, 15, 14 and 10. The response from use command is that given version is now used, however, when checking for current the response is that no version is currently used.

image

Although nvm shows that node 16.20.2 is not selected, the nodejs link points correctly. My environment variable settings are correct and node 17.9.1 can be used normally.

image

image

What did you expect to happen?

Versions below nodejs 17 should be used.

Version

1.1.11 or newer (Default)

Which version of Windows?

Windows 11+

Which locale?

Other Non-English

Which shell are you running NVM4W in?

PowerShell

User Permissions?

Administrative Privileges, Elevated

Is Developer Mode enabled?

None

Relevant log/console output

PS C:\WINDOWS\system32> nvm ls

  * 17.9.1 (Currently using 64-bit executable)
    16.20.2
PS C:\WINDOWS\system32> nvm use 16.20.2
Now using node v16.20.2 (64-bit)
PS C:\WINDOWS\system32> nvm ls

    17.9.1
    16.20.2
PS C:\WINDOWS\system32> nvm current
No current version. Run 'nvm use x.x.x' to set a version.

Debug Output

PS C:\WINDOWS\system32> nvm debug
Running NVM for Windows with administrator privileges.

管理员: Windows PowerShell
Windows Version: 10.0 (Build 22631)

NVM4W Version:      1.1.12
NVM4W Path:         D:\Apps\NVM\nvm.exe
NVM4W Settings:     D:\Apps\NVM\settings.txt
NVM_HOME:           D:\Apps\NVM
NVM_SYMLINK:        D:\Apps\NVM\nodejs
Node Installations: D:\Apps\nvm

Total Node.js Versions: 2
Active Node.js Version: none
(run "nvm use <version>" to activate a version)

IPv6 is enabled. This can slow downloads significantly.

No problems detected.

Find help at https://github.com/coreybutler/nvm-windows/wiki/Common-Issues

Anything else?

No response

coreybutler commented 5 months ago

Please correct me if I'm wrong, but the issue is just in the display, i.e. nvm ls is not showing the asterisk next to the version if it is below 17. Functionally, everything is working though, correct?

jiaohanying commented 5 months ago

No, it doesn't work. What should I do? image

Please correct me if I'm wrong, but the issue is just in the display, i.e. nvm ls is not showing the asterisk next to the version if it is below 17. Functionally, everything is working though, correct?

coreybutler commented 5 months ago

Ah, your last screenshot explains the issue. You have a NODE_OPTIONS environment variable set. Some values aren't supported in older versions of Node. --openssl-legacy-provider was blocked starting in Node 15.3.0 due to security concerns. I think Node 17+ simply ignores this while 15.3.0-16.x.x throws an error (which is what you're seeing). Remove NODE_OPTIONS or supply a value supported by the older versions to make it work.

I'm going to leave this issue open as a reminder to myself to check the NODE_OPTIONS values in a future version of the nvm debug command.