npm install cnpm -g命令报错:npm ERR! Error: EPERM: operation not permitted, rename ‘C:

系统环境: win 10 64位
nodejs 版本: node-v14.21.3
尝试过的方式:
第一种: 删除 c 盘 用户目录里 C:\Users\lifq.mpnrc 文件,无法解决
第二种: 删除 目录 C:\Users\lifq\AppData\Roaming\ 下的 npm , npm_cache文件夹, 无法解决
第三种: 使用命令 npm clean cache --force 无法解决
第四种: 修改nodejs 目录的权限(我的global , cache 都配置在这里) ,无法解决。

错误信息:

C:\Users\lifq>npm install -g cnpm --registry=http://registry.npmmirror.com
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@npmcli
npm ERR! dest D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\node-gyp\node_modules\@npmcli
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@npmcli' -> 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\node-gyp\node_modules\@npmcli'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@npmcli' -> 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\node-gyp\node_modules\@npmcli'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@npmcli' -> 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\npm\node_modules\node-gyp\node_modules\@npmcli'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'D:\\Develop\\nodejs\\node_global\\node_modules\\cnpm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@npmcli',
npm ERR!     dest: 'D:\\Develop\\nodejs\\node_global\\node_modules\\cnpm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@npmcli'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'D:\\Develop\\nodejs\\node_global\\node_modules\\cnpm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@npmcli',
npm ERR!   dest: 'D:\\Develop\\nodejs\\node_global\\node_modules\\cnpm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@npmcli',
npm ERR!   parent: 'npm'
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:
npm ERR!     D:\Develop\nodejs\node_cache\_logs\2023-04-07T08_57_24_812Z-debug.log
C:\Users\lifangqing>

报错背景:

使用的Nodejs为v14.3.0版本与要安装的cnpm版本不符

报错原因:

关键看这句

Unsupported engine for cnpm@9.4.0: wanted: {“node”:“>= 14.18.0”} (current: {“node”:“14.3.0”,“npm”:“6.14.5”})

安装cnpm9.4.0版本需要nodejs版本>= 14.18.0,我的为v14.3.0版本,所以报错。

解决办法:

解决方法一:

将Nodejs卸载重新安装最新版本v18.19.0

再次执行npm install cnpm -g命令,安装成功!

解决方法二:

安装cnpm时指定较低的版本安装:

npm install -g cnpm@6.1.0

亲测有效!

可以cnpm-v检查一下是否安装好!

  • 11
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

chaser&upper

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值