【发布时间】:2021-01-15 09:19:52
【问题描述】:
我正在尝试在 windows 10 上的 powershell 上使用 npm 安装 vue/cli。安装失败并出现以下错误。
PS C:\WINDOWS\system32> npm install -g @vue/cli
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
> yarn@1.22.10 preinstall C:\Program Files\nodejs\node_modules\@vue\cli\node_modules\yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
At line:1 char:43
+ :; (node ./preinstall.js > /dev/null 2>&1 || true)
+ ~~
The token '||' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\@vue\cli\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 @vue/compiler-sfc@3.0.0 requires a peer of vue@3.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yarn@1.22.10 preinstall: `:; (node ./preinstall.js > /dev/null 2>&1 || true)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yarn@1.22.10 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-09-29T17_51_11_839Z-debug.log
我使用的是节点版本 12.18.4
如何解决这个问题?
【问题讨论】:
-
如果不是强制要求您必须运行最新的 vue/cli 发行版,请尝试使用旧版本的软件包,例如 4.3.1(在我的情况下,这没有显示任何警告)并检查它是否在安装后仍然出现错误。显然,这会警告你 npm 有一个过时的包。
标签: node.js powershell vue.js npm vue-cli