2022-05-31 16:00阅读: 845评论: 0推荐: 0

Node.js之npm ERR code EPERM npm ERR syscall open npm ERR

1、遇到的问题

在安装vue时报下面的错误:

C:\Users\nxg>npm install -g @vue/cli
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Program Files\nodejs\node_cache\_cacache\tmp\bf1f8302
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/@vue%2fcli: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\tmp\bf1f8302'

2、解决方法

方法1:
需要删除npmrc文件。

强调:不是nodejs安装目录npm模块下的那个npmrc文件

而是在C:\Users{账户}\下的.npmrc文件…
注意:这个文件默认是被隐藏,一定要选择将隐藏取消掉
在这里插入图片描述

需要删除隐藏文件
在这里插入图片描述
方法2:

或者直接用命令清理就行,控制台输入:

npm cache clean --force

当删除之后,我们再去运行,就可以看到,我们的简单粗暴方式是很有效果的

注意在安装Vue时,也会报错,

npm install -g @vue/cli

解决办法是:使用管理员运行cmd,可以解决,如果还不能解决,就删除
把node.js安装时的目录下的package-lock.json文件删掉,分别是

D:\Program Files\nodejs\node_modules\npm\docs\package-lock.json和D:\Program Files\nodejs\node_modules\npm\node_modules\npm-normalize-package-bin\package-lock.json

附件:

具体报错如下:

C:\Users\nxg>npm install -g @vue/cli
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Program Files\nodejs\node_cache\_cacache\tmp\bf1f8302
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/@vue%2fcli: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\tmp\bf1f8302'
npm ERR!     at D:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1066:19)
npm ERR!     at async Arborist.[buildDepStep] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:935:11)
npm ERR!     at async Arborist.buildIdealTree (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.exec (D:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR!     at async module.exports (D:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5)
npm ERR!  FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/@vue%2fcli: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\tmp\bf1f8302'
npm ERR!     at D:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1066:19)
npm ERR!     at async Arborist.[buildDepStep] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:935:11)
npm ERR!     at async Arborist.buildIdealTree (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.exec (D:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR!     at async module.exports (D:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5) {
npm ERR!   code: 'EPERM',
npm ERR!   errno: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'D:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\bf1f8302',
npm ERR!   type: 'system',
npm ERR!   requiredBy: '.'
npm ERR! }
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:

C:\Users\nxg>npm install webpack -g
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Program Files\nodejs\node_cache\_cacache\tmp\03f0979a
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/webpack: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\tmp\03f0979a'
npm ERR!     at D:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1066:19)
npm ERR!     at async Arborist.[buildDepStep] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:935:11)
npm ERR!     at async Arborist.buildIdealTree (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.exec (D:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR!     at async module.exports (D:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5)
npm ERR!  FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/webpack: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\tmp\03f0979a'
npm ERR!     at D:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1066:19)
npm ERR!     at async Arborist.[buildDepStep] (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:935:11)
npm ERR!     at async Arborist.buildIdealTree (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.exec (D:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR!     at async module.exports (D:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5) {
npm ERR!   code: 'EPERM',
npm ERR!   errno: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'D:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\03f0979a',
npm ERR!   type: 'system',
npm ERR!   requiredBy: '.'
npm ERR! }
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:
posted @   所遇所思  阅读(845)  评论(0编辑  收藏  举报  
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑
  1. 1 404 not found REOL
  2. 2 偏爱 张芸京
  3. 3 Glimpse of Us Joji
偏爱 - 张芸京
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : 葛大为

作曲 : 陈伟

编曲 : 陈伟

把昨天都作废

现在你在我眼前

我想爱 请给我机会

如果我错了也承担

认定你就是答案

我不怕谁嘲笑我极端

相信自己的直觉

相信自己的直觉

顽固的人不喊累

爱上你 我不撤退

我说过 我不闪躲

我说过 我不闪躲

我非要这么做

讲不听 也偏要爱

更努力爱 让你明白

没有别条路能走

你决定要不要陪我

讲不听 偏爱

靠我感觉爱

等你的依赖

对你偏爱

痛也很愉快

把昨天都作废

把昨天都作废

现在你在我眼前

我想爱 请给我机会

如果我错了也承担

认定你就是答案

我不怕谁嘲笑我极端

相信自己的直觉

相信自己的直觉

顽固的人不喊累

爱上你 我不撤退

我说过 我不闪躲

我说过 我不闪躲

我非要这么做

讲不听 也偏要爱

更努力爱 让你明白

没有别条路能走

你决定要不要陪我

讲不听 偏爱

靠我感觉爱

等你的依赖

不后悔 有把握

不后悔 有把握

我不闪躲 我非要这么做

讲不听 也偏要爱

更努力爱 让你明白

没有别条路能走

你决定要不要陪我

讲不听 偏爱

靠我感觉爱

等你的依赖

对你偏爱 爱

痛也很愉快