关于npm配置国内淘宝镜像出错问题解决

关于npm配置国内淘宝镜像出错问题解决

今天在学习win10上安装vue环境时,在配置淘宝镜像那一步出错,出错信息如下:

C:\Users\gao>npm install -g cnpm --registry=https://registry.npm.taobao.org
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path F:\software\node_js\node_cache\_cacache
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npm.taobao.org/cnpm: EPERM: operation not permitted, mkdir 'F:\software\node_js\node_cache\_cacache'
npm ERR!     at F:\software\node_js\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1061:19)
npm ERR!     at async Arborist.[buildDepStep] (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:930:11)
npm ERR!     at async Arborist.buildIdealTree (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.install (F:\software\node_js\node_modules\npm\lib\install.js:170:5)
npm ERR!  FetchError: Invalid response body while trying to fetch https://registry.npm.taobao.org/cnpm: EPERM: operation not permitted, mkdir 'F:\software\node_js\node_cache\_cacache'
npm ERR!     at F:\software\node_js\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1061:19)
npm ERR!     at async Arborist.[buildDepStep] (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:930:11)
npm ERR!     at async Arborist.buildIdealTree (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
npm ERR!     at async Arborist.reify (F:\software\node_js\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)
npm ERR!     at async Install.install (F:\software\node_js\node_modules\npm\lib\install.js:170:5) {
npm ERR!   code: 'EPERM',
npm ERR!   errno: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'F:\\software\\node_js\\node_cache\\_cacache',
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.

我快速读了下这个报错信息,大概意思是在创建F:\\software\\node_js\\node_cache\\_cacache(F:\software\node_js是我node.js安装源目录)这个文件错误,错误原因是权限不够,然后我查看了下我的node_cache的权限,所示如下:

  1. 右键node_cache文件夹,点击属性
  2. 点击安全,发现一共有四个用户或组,有些用户的权限不够,所以修改权限,点击编辑
  3. 把这四个用户或组的所有允许下面的框全部勾上
    请添加图片描述
  4. 点击应用
    请添加图片描述
  5. 对node_global这个文件夹也执行同样的操作,使权限全打上勾勾
  6. 再次执行设置淘宝镜像源命令成功:
C:\Users\gao>npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 289 packages in 25s

补充

npm config get registry			# 查看npm仓库源
# 输出为 https://registry.npm.taobao.org/

cnpm config get registry		# 查看cnpm仓库源
# 输出为 http://registry.npm.taobao.org/
  • 31
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值