项目完成,更换下一个项目,作为一个后端,好多年不做前端的后端,要想构建一个项目并且启动起来,真的是一个特费心。。。
刚开始我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 [email protected]: 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 [email protected]: 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 [email protected]: 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 [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] 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 [email protected] requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
什么意思?
[email protected]需要一个vue@^2.6.14的依赖,但是这个依赖没有安装。您必须自己安装对等依赖项。
看样子只能安装其他版本的vue
了
#安装之前我先查询了vue
PS F:\idea_workspace_git\yd> npm info vue
[email protected] | 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 >
- yyx990803 >
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 >
太好了!直接上v3.3.11
的vue
npm install [email protected]
#省略安装日志
再次进行cnpm
的安装
#省略前面的日志
npm WARN @fullcalendar/[email protected] requires a peer of vue@^2.6.6 but none is installed. You must install peer dependencies yourself.
npm WARN @tinymce/[email protected] requires a peer of vue@^2.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN @vue/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of vue@^2.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of vue@^2.5.17 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of vue@^2.6.14 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of vue@^2.x but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
#省略后面的日志
。。。你直接说需要v2.x
不就好了么。。。干嘛说^2.6.14
#使用--legacy-peer-deps 避免出现冲突。
npm install [email protected] --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 [email protected] -g
安装完毕,再npm install cnpm
才成功的。。。。