Vue-cli 3: "command failed: npm install --loglevel error" - vue.js

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 `-- vuex#3.0.1
2737 warn ajv-keywords#2.1.1 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?

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

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 :
sudo npm cache clean -f
npm update
npm update -g #vue/cli
vue create vue-first-app

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.

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

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

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

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!

change permission by using the cli
npm config set unsafe-perm true

The problem is on the CLI
npm cache clean --force
%appdata%\npm-cache Just run on the "Run" Then Delete all the files
npm install -g #vue/cli
Just use npm 6 or greater
vue create projectName
problem solved 100% work for me
cheers

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.

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

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

Source: https://medium.com/tableless/sass-vs-stylus-28c7e2884f1a
base language
Sass: Ruby
Stylus: JavaScript
Take out sass and use stylus. It will work.

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.

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

Related

Expo-cli ReferenceError: process is not defined

I installed expo-cli 5.4.10 (node v16.14.0) after which i execute the command
yarn start
I go to the browser and see this error in the console ReferenceError: process is not defined
looking for several solutions such as (https://bobbyhadz.com/blog/react-referenceerror-process-not-defined)
I have tried the following
npm install react-scripts#latest
npm install --save-dev react-error-overlay#6.0.9
package.json
"resolutions": {
"react-error-overlay": "6.0.9"
}
but this does not solve my problem in any way, perhaps someone has come across a similar one and is ready to help me
Had same problem today.
Solution: npm i -g expo-cli#5.4.9
The web interface from cli is broken in version 5.4.10.
You can either use it with the terminal only, or use 5.4.8 (5.4.9 might work, but I haven't tested it yet)

How can resolve the NPM issue? Stuck with npm start error

The issue I have is that npm start cannot start. I tried to fix with audit, deleted node_dependency directory and re-installed with npm, nothing works.
One concrete issue I see is:
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.44.2"
Yet, I also see npm -v webpack -> 6.14.14. How do I need to debug this?
Your npm -v webpack command is not correct. it will return npm version and not the webpack version.
Try npm ls webpack . you can also check your package.json file for the packages you have. or run npm ls for the full list.
make sure to install the required dependency as it states.
Eventually I could not solve the package problem with an informed debugging.
What I did was to (npm install --global yarn) and start the application through it (yarn start). It worked a lot to download the packages and eventually started the application.
So, I guess I need to switch to yarn after this point, which is ok, as long as it works :)

Error : vue-loader requires #vue/compiler-sfc to be present in the dependency tree

I'm getting this error when I'm trying to do
npm run serve
I have tried npm update sudo npm serve. It didn't work.
I also tried deleting the package-lock.json file and doing npm install after that, and that too didn't work. I also downgraded the version of the vue-loader to 15.9.2 and that also didn't work
Actually, you are missing the library so you just have to install it with
npm i #vue/compiler-sfc
This is a new thing in vue-loader#16. To fix this, assuming you are using Vue 2, you should downgrade:
yarn add vue-loader#15
Note that you also need vue-template-compiler, the same version as the version of Vue you are using.
For us, the ones using VueJs 2!
Remember vue-loader#16 is only for VueJs 3.
Check the releases log
here.
I downgrade to the v15.9.7. It is working fine.
If you are using Dependabot, can add the a ignore rule to avoid v16 PRs:
ignore:
- dependency-name: "vue-loader"
versions: ["16.x"]
you can do this and this works for me
vue-loader#15.9.7
vue-template-compiler#2.6.1
Most likely, your problem has already been solved in one of the previous answers. But there is another least likely option in which you will receive a similar error.
The problem is in... node / npm versions. Possibly, some (non-LTS?) node/npm versions generates not quite correct dependency tree, and then trying to build unnecessary sources.
We got this error in one of our projects, when Jenkins built it on node v11.14.0 and npm 6.7.0.
But same sources are built OK on node v8.16.0 / npm 6.4.1, node v10.18.0 / npm 6.13.4 and node v14.16.0 / npm 7.8.0. We had to update node and npm to fix this issue.
Please, use this answer only as a "last chance". No need to update/rollback your node/npm environment immediately when you see this error.
For those running into this with Vue 3 and Yarn Berry, keep in mind that Vue 3 plugins are still not compatible with Yarn 2.*, so you'd have to update vue-loader section in your .yarnrc.ymlas follows:
vue-loader#*:
peerDependencies:
'#vue/compiler-sfc': '*'
webpack: '*'
I get an error when I install it directly. but it worked when I forced it.;
npm i #vue/compiler-sfc --force
You can also solve it by the following steps:
npm update
then use
npm i #vue/compiler-sfc

Cannot find module 'vuetify-loader/lib/plugin'

When I load vuetify via the vue-cli3, I get an error when i do npm run serve, saying there is a missing loader.
Docs etc and searches have come up blank.
This is a fresh project, no code loaded. Just following the instructions from the vuetify site.
Can anyone help?
I've got the same issues while creating new Vuetify app by official guide.
After adding vuetify: vue add vuetify
The missing step was installing new npm dependencies with: npm install
Later I run npm run serve and it started succesfully.
There is an issue in the documentation!
Try to manually install the package:
npm install vuetify-loader -D
you should check the vue-loader plugin path. in my case it is:
vue-loader/dist/plugin
Run npm cache clean --force. It should clear your npm cache.
For reference: https://github.com/npm/npm/issues/19072#issuecomment-345555468
I had the same problem. This whole thing worked out for me.
vue create your-app
cd your-app
npm i --save-dev --no-optional vuetify-loader vue-cli-plugin sass node-sass sass-loader
npm i
vue add vuetify
I know this looks redundant but it worked.
I got the same error when I cloned a repository and I installed the dependencies only on the master branch. When I switched to a different branch (git checkout different_branch) I forgot to install the dependencies there. So make sure you installed the dependencies before you launch the server.
Just had the same problem. In my case it was caused by placing the file vue.config.js in the top-level-folder (next to package.json) instead of in the 'src' folder.
Obviously there might be many reasons for this error, but maybe it helps someone...
do a npm install after adding vuetify as vue add vuetify then start server by
npm run serve
In your package.json: move #nuxtjs/vuetify from devDependencies to dependencies
just install the pacakge to devDependencies:
npm i --save-dev vue-loader-v16
After installing the dev dependency
npm run serve

Problems while setting up vue-cli

I'm trying to install Vue-cli environemnt via NPM.
npm install --global vue-cli
After that I want to create project
vue init webpack my-project
And I get an error
'vue' is not recognized as an internal or external command,
operable program or batch file.
I've read some solutions, most of them concern changing
PATH to C:\Users{YourUser}\AppData\Roaming\npm
Didn't work for me. Can anyone help.
I follow these commands, It's work fine for me.
npm install -g vue-cli
npm install -g vue
Edit the System environment variables, and enter the following path, and if still having a problem just try to add a path in System User Variables
C:\Program Files\nodejs\node.exe;
C:\Users\{UserName}\AppData\Roaming\npm
Check vue installed in C:\Users{UserName}\AppData\Roaming\npm
yarn add #vue/cli-service
or
npm install #vue/cli-service
is what worked for me
Well, problem was solved by simply deleting everything related to vue-cli installed before. And re-installing vue-cli.
I have faced simillar issue and re-installing vue-cli didn't work for me. Strange thing is vue and vue-cli get installed successfully but once I tried to create project by using below command
vue init webpack myfirstproject
I get below error:
'vue' is not recognized as an internal or external command,operable program or batch file.
Tried various solutions but nothing worked for me. Please find my NPM and Node details below:
NPM version: 6.2.0
Node version: 8.7.0
Actually the issue was "vue-cli" is not supporting to my Node(8.7.0). It requires Node >=8.9. Once I upgraded my Node version. everything is working fine.
upgrading your Node version is the correct way to deal with this issue
I found this same issue with another possible problem. I had
create-react-app#1.5.2 installed globally
npm list -g --depth=0 will display your globals
I simply uninstalled create-react-app
npm uninstall create-react-app
Vue vue-cli-service now works as expected.
had the same issue, i deleted my node_modules and re-install and it worked
I had the same problem after searching a lot I found this solution:
You need to Add C:\Program Files\nodejs to your PATH environment variable. To do this follow these steps:
Use the global Search to go to "Environment Variables"
Click "Edit system environment variables"
Click "Environment Variables" in the dialog
In the "System Variables" box, search for Path and edit it to include C:\Program Files\nodejs.
You will have to restart any currently-opened command prompts before it will take effect.
I hope it works, good luck!
I was installing #vue/cli using yarn, i.e. I ran
yarn global add #vue/cli
Calling vue on windows did not work after the installation ('vue' is not recognized as an internal or external command)
What I needed to do was to add C:\Users\<MY USERNAME>\AppData\Local\Yarn\bin to path.
yarn global add #vue/cli did not work for me
So I removed using yarn global remove #vue/cli
Then I installed using npm install -g #vue/cli and its working fine.
1)Try to remove all the node files, npm and nvm files/folders.
2)Also, remove the PATH of node js and nvm from environment variables.
3)try commands:
node -v
npm -v
nvm -v
above commands only to make sure that all the entities related to node are uninstalled.
4) install node, and if necessary install nvm(optioal), then run command
npm install -g #vue/cli
above procedure proven to be useful for me. Just give it a try!
for Yarn -> need to install it:
npm install -g yarn
Installing Vue CLI Package:
yarn global add #vue/cli
To create project:
vue create project-name
To run:
yarn serve
Uninstalling:
yarn global remove #vue/cli
I follow "npm" package manager instead of "yarn" package manager console because yarn give me a problem while installing it;
command to install Vue CLI:
npm install -g #vue/cli
For to create Vue project:
vue create "project-name"
For to run Vue project:
npm run serve