19
votes

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

11
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?joshas
@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 disappeardrake035

11 Answers

4
votes

Try

npm cache clean --force 

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

3
votes

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
2
votes

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.

0
votes

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!!

0
votes

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!

0
votes

change permission by using the cli

npm config set unsafe-perm true
0
votes

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

0
votes

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.

0
votes

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 ")

0
votes

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

-1
votes

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