Vue-cli 3: "command failed: npm install --loglevel error"
Asked Answered
B

18

23

Every time I try to create a new project (vue create my-project), I get this error:

ERROR : command failed: npm install --loglevel error

I'm on PC / Windows 10, Vue-cli 3.2.1, Node 8.11.3, Npm 5.6.0. Presets: Babel, ESLint & Prettier, SASS, Vue router, Vuex

From the log:

2736 silly saveTree `-- [email protected]

2737 warn [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

2738 verbose stack Error: EINVAL: invalid argument, read

Any idea what that means and how to solve it?

EDIT: I figured out that excluding any lint feature makes the problem disappear. So the question becomes: how can I still use linting and make it work?

enter image description here

Byron answered 26/12, 2018 at 16:57 Comment(4)
What preset or features did you select when creating new project? Have you tried initializing it in other drive with paths without spaces? What npm version is installed?Kobi
@joshas: just edited the question to add these details. About the drive with spaces: that is most likely unrelated, because as I say in my edit, excluding linting makes the problem disappearByron
I had same error and my problem was in Jest unit testsWane
Cmd gives warning about slow network and then advised to use useTaobaoRegistry when creating app by running cmd but still network failed with above error.Efflorescence
D
9

Try

npm cache clean --force 

If it doesn't work then manually delete %appdata%\npm-cache folder. Then try to create the project again.

Deliberative answered 15/7, 2019 at 7:2 Comment(1)
How can i find %appdata%\npm-cache in Linux?Catechize
L
5

Try pointing the npm registry url from 'https' to 'http'

Run following command :

npm config set registry="http://registry.npmjs.org/"

Then try creating vue project :

vue create my-project

It worked for me.

OR Try :

  1. sudo npm cache clean -f
  2. npm update
  3. npm update -g @vue/cli
  4. vue create vue-first-app
Lohengrin answered 10/3, 2021 at 12:31 Comment(0)
C
3

I've tried everything above but still the error kept occuring. Finally I upgraded my npm version and node version, both to the latest ones and it worked.

Catechize answered 13/7, 2020 at 19:26 Comment(0)
S
3

Try using 'Dart-Sass' instead of using 'Node-Sass'. This will create your Vue project without any errors.

Superb answered 27/11, 2021 at 9:58 Comment(0)
S
2

The reason behind the error is , u are having an outdated version of node js. Try to reinstall node js and the probelm will get fixed("dont forget to uninstall and clear all the node js file before re-installing ")

Smokeproof answered 21/3, 2021 at 18:21 Comment(0)
B
2

I had the same issue. You have to use the command vue config --set useTaobaoRegistry false. After that it worked for me.

Bombardon answered 20/5, 2021 at 15:31 Comment(1)
Yeah! That's what worked for meSpallation
F
1

I am using "vue-cli 3.0.0-rc.1", I solve the problems by setting the ~/.vuerc from "useTaobaoRegistry": true, to false. Hope it help to you!!

Figone answered 8/1, 2019 at 4:3 Comment(0)
A
1

change permission by using the cli

npm config set unsafe-perm true
Anne answered 14/3, 2020 at 22:19 Comment(0)
T
1

The problem is on the CLI

  1. npm cache clean --force
  2. %appdata%\npm-cache Just run on the "Run" Then Delete all the files
  3. npm install -g @vue/cli
  4. Just use npm 6 or greater
  5. vue create projectName

problem solved 100% work for me cheers

Trundle answered 8/11, 2020 at 18:59 Comment(0)
C
1

If you run into this issue on a Mac or Linux machine, you may simply need to sudo.

sudo vue create my-project

If you run into it on Windows, you may resolve the issue by running the terminal as admin.

Chrome answered 23/2, 2021 at 5:15 Comment(2)
he said he is using windows, so why exactly he needs sudo?Selfstarter
@RanMarciano Good call. I'll adjust my answer.Chrome
B
0

I am using vue-cli 3.7.0-rc.1, I solve the problems by editing the ~/.vuerc from "useTaobaoRegistry": false to true.

Hope it works for you!

Bayadere answered 29/4, 2019 at 9:19 Comment(0)
M
0

Likely issue is your proxy settings:

I was having this issue recur intermittently and in the end I found out it was being caused by network proxy issues. See this article on how run npm behind a proxy server

Moten answered 9/7, 2020 at 14:43 Comment(0)
V
0

I had same issue when i was installing vue-cli with npx .... tried all the solutions from google.. nothing worked for me ..

so then i moved to install vue-cli with yarn package manager thats when i figured out the issue .. my issue was basically my node version which was 8.x.x but yarn was expecting 10.x.x with nvm i have installed latest node which is 16.x.x then tried installing vue-cli with yarn ..

it worked like charm!!!!

Vertievertiginous answered 29/7, 2021 at 4:44 Comment(0)
H
0

Source: https://medium.com/tableless/sass-vs-stylus-28c7e2884f1a

base language Sass: Ruby Stylus: JavaScript

Take out sass and use stylus. It will work.

Hulse answered 27/11, 2021 at 0:19 Comment(2)
A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.Autostrada
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewMathieu
T
0

I had the same issue using Ubuntu 20.04 OS. I used the command

npm install --loglevel error --legacy-peer-deps

and it worked for me.

Taddeo answered 14/7, 2022 at 15:27 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Preceptive
Z
0

Best one liner solution to solve this problem permanently

Run the following command in your terminal in the same folder where you are creating the vue project:

sudo chown -R 501:20 "/Users/programera/.npm"
Zoril answered 28/3, 2023 at 3:46 Comment(0)
E
0

I had the clue in the error message with the similar problem, when creating new VueJS project on Mac:

npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /Users/<username>/.npm/_cacache/index- 
v5/25/ee/12345
npm ERR! errno EACCES
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 501:20 "/Users/vaidas/.npm"

After running sudo chown -R 501:20 "/Users/vaidas/.npm" problems were fixed.

Escuage answered 26/3 at 11:10 Comment(0)
D
0

I also encountered this problem and figure it out by doing followings:

  1. change https to http:
    npm config set registry="http://registry.npmjs.org/"
    
  2. clean cache
    npm clean cache --force
    
Dogmatize answered 2/7 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.