运行 "npm install -g @vue/cli" 时出错,多次尝试重新安装

Error when running "npm install -g @vue/cli", reinstall attempted many times

我在这个问题上卡了很久。当我运行 npm install -g @vue/cli时,弹出如下错误。当我 运行 vue 创建项目名称时也会出现类似的错误。我试过多次重新安装,也试过清理缓存。我很清楚错误“C:\Users\zhang\node_modules.bin/../node/bin/node”中的字典不存在,但我不知道如何修复它。

C:\Users\zhang>npm install -g @vue/cli
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm ERR! code 127
npm ERR! path C:\Users\zhang\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\core-js-pure
npm ERR! command failed
npm ERR! command D:\Program Files\git\bin\bash.exe -c node -e "try{require('./postinstall')}catch(e){}"
npm ERR! /c/Users/zhang/node_modules/.bin/node: line 8: C:\Users\zhang\node_modules\.bin/../node/bin/node: No such file or directory

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zhang\AppData\Local\npm-cache\_logs21-05-02T21_16_30_121Z-debug.log

我已经坚持了好几个小时,非常感谢您的帮助

谢谢!

WARN 不是问题。

它确实无法 运行 节点二进制文件。 npm ERR! /c/Users/zhang/node_modules/.bin/node: line 8: C:\Users\zhang\node_modules\.bin/../node/bin/node: No such file or directory

确保您选择了正确的路径。或者相应地更改 env PATH 变量。

请遵循其中任何一个以避免这些

1.sett环境路径正确

2.make确定当前用户有权限处理数据

ls -la /usr/lib/node_modules whoami sudo chown -R $USER /usr/lib/node_modules(setting the permission to current user)

3.Install 作为 sudo 用户的 npm

sudo npm i -g @vue/cli