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]: npm install -g @vue/cli 'vue' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 #1108

Closed a1005380483 closed 7 months ago

a1005380483 commented 7 months ago

What happened?

当我在node -v 20.11.1 21.6.2 18.19.1 12.22.12 8.9.3分别执行npm install -g @vue/cli 时,均在vue -v 时提示'vue' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 npm uninstall -g @vue/cli 重新nvm use xx.xx.xx再install依旧是这个问题,S:\global_npm\node_module\node_modules\node_modules\node_modules可以找到已安装的vue包,uninstall也能正常卸载,但就是vue -v报错,包括express也是报错

我查看了Vue is not recognized after npm -g install #433 并不能帮助到我。 安装时修改到了S:\nodejs S:\nvm,路径中并没有中文,也没有手动安装,都是用的nvm/npm

What did you expect to happen?

我希望vue -v能正常执行,输出相应的vue-cli版本,希望全局包能顺利执行,因为我需要安装npm-check-updates,这对我项目升级很重要,我需要试node版本兼容性,不可能抛开nvm不用

Version

1.1.11 or newer (Default)

Which version of Windows?

Windows 10 (Default)

Which locale?

English (Default)

Which shell are you running NVM4W in?

Command Prompt, PowerShell

User Permissions?

Administrative Privileges, Elevated

Is Developer Mode enabled?

No (Default)

Relevant log/console output

No response

Debug Output

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

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

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

Total Node.js Versions: 9
Active Node.js Version: v20.11.1

IPv6 is enabled. This can slow downloads significantly.

PROBLEMS DETECTED
-----------------
The following Node installations are invalid (missing node.exe): v12.22.12, v10.24.1, v8.17.0, v6.17.1, v4.9.1 - consider reinstalling these versions

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

Anything else?

No response

a1005380483 commented 7 months ago

我发现了,可能是我修改了nodejs和nvm地址,因此我的npn config get prefix和npm root -g路径不一致,重新修改跟npm root -g路径一致就可以了,但疑惑的是明明我是S:\global_npm\node_module\node_modules\node_modules\node_modules\@vue 四个node_modules,但设置变量只能设置三个,否则就会报错,这也是为什么一开始我没找到问题的原因。因为我一直觉得应该是四个才对

quhaisi commented 3 months ago

This issue might be caused by PowerShell's execution policy. It can be adjusted using Set-ExecutionPolicy, but this may pose security risks.