npm install cnpm遇到的问题

2023-12-13 14:39:06

项目完成,更换下一个项目,作为一个后端,好多年不做前端的后端,要想构建一个项目并且启动起来,真的是一个特费心。。。
刚开始我npm install总是报错,傍边的小伙伴说,用cnpm命令就可以了。
然后我使用cnpm发现没有这个命令

#安装cnpm命令
npm install -g cnpm --registry=https://registry.npm.taobao.org

结果报错如下:

PS F:\idea_workspace_git\yd> npm install cnpm  --legacy-peer-deps
npm WARN deprecated fsevents@1.2.13: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^2.3.2 (node_modules\jest-haste-map\node_modules\fsevents):                                              
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):                                                    
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.3 (node_modules\sane\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN v-scale-screen@1.0.2 requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN d-web@3.4.1 No repository field.

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\.make-fetch-happen.DELETE\node_modules\@npmcli
npm ERR! dest F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\make-fetch-happen\node_modules\@npmcli
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\.make-fetch-happen.DELETE\node_
modules\@npmcli' -> 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\make-fetch-happen\node_modules\@npmcli'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\.make-fetch-happen
.DELETE\node_modules\@npmcli' -> 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\make-fetch-happen\node_modules\@npmcli'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\.make-fetch-happen.DE
LETE\node_modules\@npmcli' -> 'F:\idea_workspace_git\yd\node_modules\cnpm\node_modules\make-fetch-happen\node_modules\@npmcli'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'F:\\idea_workspace_git\\yd\\node_modules\\cnpm\\node_modules\\.make-fetch-happen.DELETE\\node_modules\\@npmcli',
npm ERR!     dest: 'F:\\idea_workspace_git\\yd\\node_modules\\cnpm\\node_modules\\make-fetch-happen\\node_modules\\@npmcli'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'F:\\idea_workspace_git\\yd\\node_modules\\cnpm\\node_modules\\.make-fetch-happen.DELETE\\node_modules\\@npmcli',
npm ERR!   dest: 'F:\\idea_workspace_git\\yd\\node_modules\\cnpm\\node_modules\\make-fetch-happen\\node_modules\\@npmcli',
npm ERR!   parent: 'cnpm'
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!     F:\node.js\node_cache\_logs\2023-12-12T06_19_04_476Z-debug.log

刚开始一直以为是权限的问题,文件加权后,npm install cnpm 还是报这个错,问题就根本没解决。

于是我详细阅读日志,最后在上文中发现了一行日志

npm WARN v-scale-screen@1.0.2 requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN d-web@3.4.1 No repository field.

什么意思?
v-scale-screen@1.0.2需要一个vue@^2.6.14的依赖,但是这个依赖没有安装。您必须自己安装对等依赖项。
在这里插入图片描述
看样子只能安装其他版本的vue

#安装之前我先查询了vue
PS F:\idea_workspace_git\yd> npm info vue

vue@3.3.11 | MIT | deps: 5 | versions: 458
The progressive JavaScript framework for building modern web UI.

keywords: vue

dist
.tarball: https://registry.npmmirror.com/vue/-/vue-3.3.11.tgz
.shasum: 898d97025f73cdb5fc4e3ae3fd07a54615232140
.integrity: sha512-d4oBctG92CRO1cQfVBZp6WJAs0n8AK4Xf5fNjQCBeKCvMI1efGQ5E3Alt1slFJS9fZuPcFoiAiqFvQlv1X7t/w==
.unpackedSize: 2.0 MB

dependencies:
@vue/compiler-dom: 3.3.11    @vue/compiler-sfc: 3.3.11    @vue/runtime-dom: 3.3.11     @vue/server-renderer: 3.3.11 @vue/shared: 3.3.11

maintainers:
- posva <posva13@gmail.com>
- yyx990803 <yyx990803@gmail.com>

dist-tags:
alpha: 3.4.0-alpha.4      csp: 1.0.28-csp           legacy: 2.6.14            v2-alpha: 2.7.0-alpha.12  v2-latest: 2.7.15
beta: 3.3.0-beta.5        latest: 3.3.11            next: 3.2.36              v2-beta: 2.7.16-beta.1

published 4 days ago by yyx990803 <yyx990803@gmail.com>

太好了!直接上v3.3.11vue

npm install vue@3.3.11
#省略安装日志

再次进行cnpm的安装

#省略前面的日志
npm WARN @fullcalendar/vue@4.4.2 requires a peer of vue@^2.6.6 but none is installed. You must install peer dependencies yourself.
npm WARN @tinymce/tinymce-vue@3.2.8 requires a peer of vue@^2.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN @vue/test-utils@1.0.0-beta.29 requires a peer of vue@2.x but none is installed. You must install peer dependencies yourself.
npm WARN ant-design-vue@1.7.8 requires a peer of vue@^2.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN element-ui@2.15.5 requires a peer of vue@^2.5.17 but none is installed. You must install peer dependencies yourself.
npm WARN v-scale-screen@1.0.2 requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN vue-jest@3.0.7 requires a peer of vue@^2.x but none is installed. You must install peer dependencies yourself.
npm WARN d-web@3.4.1 No repository field.
#省略后面的日志

。。。你直接说需要v2.x不就好了么。。。干嘛说^2.6.14

#使用--legacy-peer-deps 避免出现冲突。
npm install vue@2.6.14  --legacy-peer-deps

装完那之后,继续npm install cnpm
还是报错…
在这里插入图片描述
准备清楚缓存,重新下载依赖。事情出现了转机…

#清除缓存
PS F:\idea_workspace_git\yd> npm cache clean --force
npm WARN using --force Recommended protections disabled.
PS F:\idea_workspace_git\yd> npm cache clean -f
npm WARN using --force Recommended protections disabled.

啥意思???禁止使用该命令
CSND了一下,说是npm版本太高了

#于是,我就用npm安装低版本的npm。。。
npm install npm@6.14.10 -g

安装完毕,再npm install cnpm才成功的。。。。

文章来源:https://blog.csdn.net/qq_32605245/article/details/134948828
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。