系统环境: 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
检查一下是否安装好!