【问题标题】:Error with vue/cli installation on windows在 windows 上安装 vue/cli 时出错
【发布时间】: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


【解决方案1】:

看来 1.22.10 版本的 yarn 以 root 身份安装 node 时在 windows 上会出现问题。你可以试试 1.22.5 看看能不能解决

https://github.com/yarnpkg/yarn/blob/master/CHANGELOG.md#12210-and-prior

【讨论】:

    【解决方案2】:

    这个错误似乎存在于最近 1.22.7 的某些 NPM 版本中。

    我在这里看到了一些与此错误相关的讨论:https://github.com/yarnpkg/yarn/issues/8358

    使用 sudo 前缀更新 NPM 本身为我解决了这个问题(在 Ubuntu 上)。奇怪的是,我运行它的环境是 root 帐户。

    sudo npm install -g npm
    

    然后,安装带有 sudo 前缀的纱线修复了我的安装:

    sudo npm install -g yarn
    

    我认为这是旧版本 NPM 或 yarn 的错误。通过使用 NPM 进行自我更新,你可以获得最新版本的 NPM,其中可能有最新版本的 yarn。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-19
      • 1970-01-01
      • 2021-07-01
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      • 2013-02-25
      相关资源
      最近更新 更多