coreybutler / nvm-windows

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

[Issue]: Cannot switch nodejs #1147

Open AlexanderDash opened 2 weeks ago

AlexanderDash commented 2 weeks ago

What happened?

C:\Users\alexa>nvm ls

20.11.0

C:\Users\alexa>nvm use 20 node v20.11.0 (64-bit) is not installed.

C:\Users\alexa>nvm use 20.11.0 node v20.11.0 (64-bit) is not installed.

why?????????????????????????????????????????????????????

What did you expect to happen?

fix

Version

1.1.11 or newer (Default)

Which version of Windows?

Windows 11+

Which locale?

None

Which shell are you running NVM4W in?

No response

User Permissions?

Administrative Privileges, Elevated

Is Developer Mode enabled?

None

Relevant log/console output

No response

Debug Output

.

Anything else?

No response

coreybutler commented 2 weeks ago

Not enough info. Please run nvm debug and paste the results here.

AlexanderDash commented 2 weeks ago

image My computer is a Windows 11 ARM architecture CPU 8cxgen3. I downloaded the Windows ARM version of nodejs from the official website and placed it in D: \ Program Files \ nvm. Although it is arm64 bit, the message returned by nvm is 32bit... I tried NVM install 20.14.0 and downloaded nodejs 20.14.0 x64 bit. Then, I deleted all the files inside and copied the arm version of nodejs into this folder. Then, I entered NVM ls and it displayed 32 bit. Then, I used NVM 16 to switch to another version. Then NVM uses 20 and displays node v20.14.0 (64 bit) as not installed. I don't know what bug this is, and NVM cannot download arm64 version of nodejs............

Not enough info. Please run nvm debug and paste the results here.

AlexanderDash commented 2 weeks ago

(base) PS D:\HBuilderProjects\PicSelect> nvm debug alexa is not using admin or elevated rights.

C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe Windows Version: 10.0 (Build 22631)

Windows Developer Mode: UNKNOWN (user cannot read registry)

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

Total Node.js Versions: 2 Active Node.js Version: v16.20.2

IPv6 is enabled. This can slow downloads significantly.

No problems detected.

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

coreybutler commented 2 weeks ago

I'm not sure how it got into this state, but run nvm install 20 64 to force the 64-bit install.

The primary issue appears to be a user account lacking permission to use mklink (the underlying windows utility used to generate symlinks). See permission issues.

AlexanderDash commented 2 weeks ago

C:\Users\alexa>nvm debug Running NVM for Windows with administrator privileges.

管理员: 命令提示符 - nvm debug Windows Version: 10.0 (Build 22631)

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

Total Node.js Versions: 2 Active Node.js Version: v16.20.2

IPv6 is enabled. This can slow downloads significantly.

PROBLEMS DETECTED

"管理员: 命令提示符 - nvm debug" is not an officially supported shell. Some features may not work as expected.

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

C:\Users\alexa>nvm ls

20.14.0

C:\Users\alexa>nvm use 20 node v20.14.0 (64-bit) is not installed.

C:\Users\alexa>nvm use 20.14.0 node v20.14.0 (64-bit) is not installed.

C:\Users\alexa>nvm debug Running NVM for Windows with administrator privileges.

管理员: 命令提示符 - nvm debug Windows Version: 10.0 (Build 22631)

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

Total Node.js Versions: 2 Active Node.js Version: v16.20.2

IPv6 is enabled. This can slow downloads significantly.

PROBLEMS DETECTED

"管理员: 命令提示符 - nvm debug" is not an officially supported shell. Some features may not work as expected.

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

C:\Users\alexa>nvm ls

20.14.0

C:\Users\alexa>nvm use 20 node v20.14.0 (64-bit) is not installed.

C:\Users\alexa>nvm use 20.14.0 node v20.14.0 (64-bit) is not installed.

C:\Users\alexa>nvm use 20.14.0 32-bit node v20.14.0 (64-bit) is not installed.

It's not a permission issue. You see, even though I'm currently in the administrator cmd, I still can't solve the problem. NVM has recognized the ARM 64bit version of nodejs as 32-bit.. I think that's the key. NVM does not consider arm64 bit to be 64 bit...

image

I'm not sure how it got into this state, but run nvm install 20 64 to force the 64-bit install.

The primary issue appears to be a user account lacking permission to use mklink (the underlying windows utility used to generate symlinks). See permission issues.

AlexanderDash commented 2 weeks ago

(base) PS D:\HBuilderProjects\PicSelect> nvm install 20 Downloading node.js version 20.14.0 (64-bit)... Extracting node and npm... Complete npm v10.7.0 installed successfully.

Installation complete. If you want to use this version, type

nvm use 20.14.0 (base) PS D:\HBuilderProjects\PicSelect> nvm use 16 Now using node v16.20.2 (64-bit) (base) PS D:\HBuilderProjects\PicSelect> nvm ls

20.14.0

You see, I deleted the folder of nodejs v20 from the original arm64, and then NVM installed 20. It can switch normally..

coreybutler commented 2 weeks ago

OK, so if the executable is actually 64 bit, then it is actually 64-bit. Detecting architecture of an executable is a bit of a hack and won't always work. Since there isn't direct arm support yet (there is a PR I plan to merge to support this), I suspect the architecture detection simply isn't accounting for arm.

There's not a lot I ca do about this immediately, but once arm support is added, I believe this issue will be resolved. I'll leave this open until the PR is merged and will readdress this after that is complete.