上个月我安装了 Node 10.16.3 LTS,因为它没有最新的 npm 版本,所以我使用官方指南更新了它:https://docs.npmjs.com/try-the-latest-stable-version-of-npm (选项2):
- 删除了 %ProgramFiles%\nodejs\npm 和 %ProgramFiles%\nodejs\npm.cmd
- 已将“npmrc”文件从 %ProgramFiles%\nodejs\node_modules\npm 移至 %appdata%\npm\node_modules\npm
今天,在我安装“create-react-app”后,npm 向我显示消息,npm 的新次要版本已可用 6.11.3 -> 6.12.0,我可以更新它。
我运行了“npm install -g npm@latest”,但这只是给我带来了一堆错误:
C:\Users\Wladyslaw\AppData\Roaming\npm\npx -> C:\Users\Wladyslaw\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Users\Wladyslaw\AppData\Roaming\npm\npm
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\Wladyslaw\AppData\Roaming\npm\npm'
npm ERR! { [Error: EPERM: operation not permitted, open 'C:\Users\Wladyslaw\AppData\Roaming\npm\npm']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, open 'C:\Users\Wladyslaw\AppData\Roaming\npm\npm'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Users\\Wladyslaw\\AppData\\Roaming\\npm\\npm' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, open \'C:\\Users\\Wladyslaw\\AppData\\Roaming\\npm\\npm\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Users\\Wladyslaw\\AppData\\Roaming\\npm\\npm' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Wladyslaw\AppData\Roaming\npm-cache\_logs\2019-10-17T19_35_58_442Z-debug.log
现在我什至无法运行“npm -v”,它以某种方式删除了我的 npm 文件夹并只向我显示此消息:
bash: /c/Users/Wladyslaw/AppData/Roaming/npm/npm: No such file or directory
有没有办法修复这种损坏的 npm 安装,而无需重新安装整个 Node.js?
谢谢
最佳答案
您刚刚以管理员身份运行命令行
关于node.js - "npm install -g npm@latest"损坏了我的 npm 安装 - Windows 8.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58441336/