在windows上安装vue/cli时出错



我正试图在windows 10的powershell上使用npm安装vue/cli。安装失败,出现以下错误。

PS C:WINDOWSsystem32> 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 Filesnodejsnode_modules@vueclinode_modulesyarn
> :; (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@vueclinode_moduleschokidarnode_modulesfsevents):
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:UsersUserAppDataRoamingnpm-cache_logs2020-09-29T17_51_11_839Z-debug.log

我使用的是节点版本12.18.4

如何解决此问题?

当node作为root安装时,看起来1.22.10版本的yarn在windows上会出现问题。你可以试试1.22.5,看看是否能修复

https://github.com/yarnpkg/yarn/blob/master/CHANGELOG.md#12210-和以前的

此错误似乎出现在1.22.7等新版本的NPM中。

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

sudo前缀更新NPM本身为我(在Ubuntu上(解决了这个问题。奇怪的是,我运行这个程序的环境是一个根帐户。

sudo npm install -g npm

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

sudo npm install -g yarn

我认为这是旧版本的NPM或纱线上的一个错误。通过使用NPM更新自身,您可以获得最新版本的NPM,它可能具有最新版本纱线。

最新更新