Error with vue/cli installation on windows

1.8k Views Asked by At

I am trying to install vue/cli using npm on powershell on windows 10. The installation fails with the following error.

PS C:\WINDOWS\system32> npm install -g @vue/cli
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

> [email protected] 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 [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @vue/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] preinstall: `:; (node ./preinstall.js > /dev/null 2>&1 || true)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

I am using node version 12.18.4

How to fix this issue?

2

There are 2 best solutions below

0
rge On

It seems the 1.22.10 version of yarn will have problems on windows when node was installed as root. You could try 1.22.5 and see if that fixes it

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

0
Ryan Alex Martin On

This bug seems to be in some versions of NPM as recent as 1.22.7.

I saw some discussion related to this bug here: https://github.com/yarnpkg/yarn/issues/8358

Updating NPM itself with the sudo prefix solves the issue for me (on Ubuntu). Strangely enough, the environment I was running this from was a root account.

sudo npm install -g npm

Then, installing yarn with the sudo prefix fixes my install:

sudo npm install -g yarn

I presume this is a bug on older versions of NPM or yarn. By using NPM to update itself, you can get the latest version of NPM, which likely has the latest version of yarn.