Related
While installing the dependencies of vue-cli, vue is not identified. Why?
rm -rf node_modules and npm install again
have a look here
Add sudo before yarn when installing
yarn global remove #vue/cli
sudo yarn global add #vue/cli
vue
I had the same issue for a while.
TL;DR
npm install #vue/cli-service --save-dev
As the documentation specify it is a development dependency https://cli.vuejs.org/guide/#cli-service
The CLI Service (#vue/cli-service) is a development dependency. It's an npm package installed locally into every project created by #vue/cli.
Origin
I had a fresh install of nodejs
And just did
>> sudo npm install -g #vue/cli#latest
>> vue --version
#vue/cli 4.5.8
The issue
The issue presented like this
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
/bin/sh: 1: vue-cli-service: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The fixes:
npm install #vue/cli-service --save-dev
Which led me straight to another error message
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
ERROR Error: Cannot find module 'vue-template-compiler/package.json'
Which I fixed the same way
npm i vue-template-compiler --save-dev
And now it is working fine.
Installing current version without permanently installing vue-cli.
npx #vue/cli create appname
It shows the vue executable is located at /home/alisha/.local/bin. So probably this location is not there in your $PATH.
You should be able to run the vue commands if you provide the full path, like:
~/.local/bin/vue create hello-world
You can also see if that directory is in your PATH by running some command like:
echo $PATH | grep '.local/bin/'
If it's there, you would see it, otherwise you can add it to your path by placing it in your ~/.profile.
Edit ~/.profile and add the following at the bottom of it.
PATH="$HOME/.local/bin:$PATH"
Hope it helps!!
I had the same issue while making a build for production.
You will require vue-cli to be installed. Use below command to install the latest version.
npm install -g #vue/cli#latest
Then
npm install
Might have to do with you having an old version on your computer:
Warning regarding Previous Versions
The package name changed from vue-cli to #vue/cli. If you have the previous vue-cli (1.x or 2.x) package installed globally, you need to uninstall it first with
npm uninstall vue-cli -g or yarn global remove vue-cli.
You can find it here: https://cli.vuejs.org/guide/installation.html
THIS FIXED THE ISSUE FOR ME:
After running
sudo npm install -g #vue/cli
I ran
sudo nano $HOME/.profile
and pasted the following line
export PATH=$PATH:/home/chike/.npm-global/bin
after writing the code, next thing I did was Ctrl + O, ENTER and Ctrl + X then wrote
vue init webpack myapp
When you install vue using cli that time you got the path of vue.Now you can copy the bin folder path.
In my example /home/sublime/.npm-packages/bin
Now you export the path below command
export PATH=$PATH:/home/sublime/.npm-packages/bin
I solved mine by running (add sudo if needed)
npm i -g vue-cli#2.9.6
npm i -g #vue/cli
Got similar issue when deploy vue project in jenkins.
Here is what I did:
Add node's bin/ dir, to jenkins user's .bashrc file.
e.g
# node
NODE_HOME=/home/dev/.nvm/versions/node/default
PATH=$NODE_HOME/bin:$PATH
Tips - about nvm & yarn
When you manage node version via nvm, make sure you already choose the node version in terminal. e.g:
nvm use stable
node -v
If you use nvm, and installed yarn via npm, then better install vue-cli via npm not yarn, otherwise the vue executable is not placed into node's bin/ dir, at least that's the case in my tests, and as a result will cause you fail to find the vue command.
Using Yarn on Ubuntu it is installed to ~/.npm-packages/bin/. You must add this directory to your PATH. For example run the following command, close your terminal and open a new one.
user#machine:~$ echo 'export PATH="$PATH:~/.npm-packages/bin/"' >> ~/.bashrc
Note: if the file ~/.bashrc does not exist then simply create it.
Following worked for me:
First remove all the existing ones:
yarn global remove #vue/cli
yarn global remove #vue/cli-service
sudo yarn global remove #vue/cli
sudo yarn global remove #vue/cli-service
Then add #vue/cli using sudo:
Note: use sudo if required
yarn global add #vue/cli
yarn global add #vue/cli-service
Then, the final thing to do is to RESTART the terminal.
vue --version
#vue/cli 4.5.9
If you already got a project, the only two things you need to do is:
Delete the directory node_modules (it is safe, since it is not under git and will regenerate in the next step)
In the command-line write yarn install (it will install everything you need)
If you start installing vue-cli manually in a existing project, it the package.json and package-lock.json will be updated. If you already did. Do a checkout from git, and follow my steps above
This may be a problem caused by version conflicts. "export PATH=$PATH:" This is really useful in some cases. But if you are also like me, after trying the direct “export path” method in the comment above, restarting the terminal still can not execute the situation, you can try this way.
Uninstall Vue
npm uninstall -g #vue/cli
Check the local-global npm package installation path, vue is installed in this directory, check if it has been removed.
npm root -g
Install vue (you can check with https://cli.vuejs.org/#getting-started to find the latest command)
npm install -g #vue/cli
Create a connection to the /usr/local/bin directory(You need to find the vue.js path after the local installation first, then replace this path with your latest local install path:/Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js)
ln -s /Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js /usr/local/bin/vue
View version number
vue -v
I was getting the same error because Node.js was not installed. My issue got resolved by installing Node.js using the following command:
sudo apt install nodejs-legacy
To see if you already have Node.js and npm installed and check the installed version, run the following commands:
node -v
npm -v
If both are installed then follow the steps here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I installed the package using yarn global add #vue/cli on my Ubuntu box and found the binary in /home/vonkad/.yarn/bin.
I had to modify my /home/vonkad/.bashrc and add the directory to the path export PATH=$PATH:/home/vonkad/.yarn/bin.
To fix this situation, I had to add the following line to my .zshrc (maybe in your case is .bashrc)
export PATH="$(yarn global bin):$PATH"
Effectively, the yarn global bin is a folder where vue (vue-cli 3) was placed.
What helped me
mac os catalina with zsh terminal
Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Downloaded node/npm from https://nodejs.org/en/download/current/
sudo npm install -g #vue/cli
vue --version (#vue/cli 4.5.4)
I faced the same issue and now resolved. In my case I installed Node.js and NPM using the default Ubuntu repository by using this command sudo apt-get install nodejs npm
The problems seemed like those 2 packages are not well maintained so it caused some bugs.
So I purge those packages and reinstall it from nodesource which is officially recommended way to install (reference: Installation instruction from nodesource) using these commands.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Then reinstall #vue/cli again
sudo npm install -g #vue/cli
Now these issues have gone. Hope it helps some programmers.
You need to install vue via sudo like explained in the doc:
https://cli.vuejs.org/guide/installation.html
If you have WSL2 running and you use zsh like me, just add
yarn global add #vue/cli
# add this line to ~/.zshrc
export PATH="$HOME/.yarn/bin:$PATH"
$ vue --version
#vue/cli 4.x.xx
You can try the following code install see
npm install --global vue-cli
vue init webpack <YOUR-PROJECT-NAME-HERE>
cd <YOUR-PROJECT-NAME-HERE>
npm install
npm run dev
As the title says, I cannot run create-react-app.
You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
Doing this does not change the error. npm uninstall -g create-react-app
I entered this command to try it out and got a message that the tar was out of date.
npm install -g create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code EEXIST
npm ERR! path /opt/homebrew/bin/create-react-app
npm ERR! EEXIST: file already exists
npm ERR! File exists: /opt/homebrew/bin/create-react-app
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
https://www.npmjs.com/package/tar
I ran the command with this reference.
However, the tar was not updated.
I have already tried all the published solutions, but they don't work. Can someone please help me? Please.
I tried clearing the cache but could not solve the problem.
npx clear-npx-cache
Need to install the following packages:
clear-npx-cache
Ok to proceed? (y) y
I was able to successfully run the following command by specifying the version each time, but it is a hassle and I want to be able to run it normally.
npx create-react-app#latest my-app
The "fish" shell I am currently using is node v18.0.0, so I downgraded to v16.15.0 and it works fine.
fisher install jorgebucaran/nvm.fish
nvm install v16
I had forgotten to lower the node version in fish because it had been working fine with zsh.
this is the problem
HP#DESKTOP-1HP83V8 MINGW64 ~/Desktop/Web-Development (master)
$ npx create-react-app my-app
Creating a new React app in C:\Users\HP\Desktop\Web-Development\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2020-11-20T11_50_51_060Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts >cra-template has failed.
I've encountered this multiple times.
First I would suggest that you run npm uninstall -g create-react-app since the global version isn't supported anymore.
Then try npx create-react-app my-app again.
If that does not work, try to run:
npm init
npm install create-react-app
npx create-react-app my-app
The steps above have solved the issue for me a couple of times
Disconnect and reconnect to your source of internet (WIFI).
After that, run npm cache verify
Next you will want to run: rerun npx create
Working Solution: thanks to idkwhatsgoingon's answer.
create-react-app does not work globally
npm uninstall -g create-react-app
npm install create-react-app
create-react-app app01
try this command first:
npm cache clean --force
and create your react app again.
I got the same error .Here these things i did to solve it
I ran npm cache clean --force
after again npx create-react-app project name
I tried all of these, it did not work. But I restarted the computer and it started working ! So after clearing the cache etc, might be be worth restarting the machine ( Windows 10 )
I got the same error when trying to install netlify-cli.
Here are two things I did to solve it:
I deleted some files to clear up disk space
Since my npm version is 6.0+, I ran "sudo npm cache verify"
Add the line
timeout=60000
to your .npmrc config file (create it at ~/.npmrc if it doesn't exist)
then run npx create-react-app project-name should be successful. At least it was in my case. (I had code ERR_SOCKET_TIMEOUT before)
Try installing yarn. I did this and immediately fixed my issues.
npm install --global yarn
first and foremost uninstall create-react-app by
npm uninstall -g create-react-app
then
npm cache clean -f
then
npx create-react-app app-name
this worked for me
I run npm cache verify
After this command, I run sudo apt install rerun
Then I run the command rerun npx create-react-app <app-name>
It worked like magic
When I was trying to create a new react app using npx create-react-app example_app, I get this error
[Your cache folder contains root-owned files, due to a bug in previous
versions of npm which has since been addressed sudo chown -R 0:0
"/root/.npm"]
I even tried to re-install create-react-app again using npm i create-react-app, it is giving the same kind of
error.
I assume after searching about it that it is due to some permissions issue. My current user doesn't have permission to /home/shubham/.npm where shubham is my username, but I am not so sure about this.
I have tried to solve this error using chown command as
sudo chown -R <username>:<groupname> /home/shubham/.npm"
where <username> is Shubham and <groupame> is 1000, but it is still not working.
Request people to help me out.
If you need any more information, let me know.
This worked for me:
sudo npm cache clean --force
This is what helped me after going through the above answers. I hope it helps someone else too. After re-reading the npm error prompt, I adjusted the provided command to include the .npm path given in the error message. Below is a copy of my original error messages.
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /home/vagrant/.npm-global/lib/node_modules
npm ERR! errno -13
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 900:900 "/home/vagrant/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2020-07-09T16_43_35_046Z-debug.log
[ExecStack] Exit code 243 Time 01:03
[error] Executing target-hook frontend-reqs failed.
[error] Command source:build:frontend-reqs exited with code 1.
Instead of using sudo chown -R 900:900 "/home/vagrant/.npm", I used sudo chown -R 900:900 "/home/vagrant/.npm-global". After that, I was able to use the previous command that caused the error with no issues.
Set the npm_config_cache environment variable
in linux
export npm_config_cache=/path/to/cache
in windows
set npm_config_cache=/path/to/cache
Try sudo chown -R 1000:1000 "/home/shubham/.npm"
I had to do both the root folder and the root/.npm
sudo chown -R 1001:1001 "/root"
sudo chown -R 1001:1001 "/root/.npm"
If you are using CI and share the CI slave with other teams, maybe not possible to sudo chown -R {group}:{user} "~/.npm" (i.e.: using Github Enterprise with Github Actions on shared runners
I add
# use local cache to work-around 'npm ERR! path ~/.npm/_locks/staging-xxx.lock' in GHA
cache=./npm-cache
into my .npmrc in the repo to solve the issue by using local npm cache dir
I had the same issue and several others while trying to update my npm packages. I will be honest I do not have enough knowledge of package handlers or why this fixed my situation, but I believe my version of npm and npx were causing the issues. I had errors immediately trying to install npx, node and create-react-app with my old and out of date version of npm.
I could not run npm install npx -g without --force. Once I did that I also ran npm install npm -g --force. After this I could already tell things were different.
After npm and npx were completely overwritten, I ran npm install node -g and npm install create-react-app -g without any weird problems. I created a new react app and started it error free.
(I also ran the cache command before all of this. sudo npm cache clean --force which I am unsure if it helped).
I was getting this while running npx #11ty/eleventy as root:
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 1000:1000 "/root/.npm"
No, /root/.npm is supposed to be owned by root. It's not at all due to a bug in a previous version of npm. And yes, the root user has permission to read and write that directory. So this is a bug in the current version of npm that prevents building the project as root.
Of course following the nonsensical instructions to change the root homedir's ownership does not work.
In my case, I was running it as root as part of a build script that needs root for an rsync to complete:
#!/bin/bash -eu
# mybuildscript
npx #11ty/eleventy
rsync _site/ /srv/www/ # This needs to be run as root
So my workaround was to run that single line as an unprivileged user using sudo:
#!/bin/bash -eu
# mybuildscript
sudo -u ki9 npx #11ty/eleventy
rsync _site/ /srv/www/ # This needs to be run as root
I am using npm version 7.5.2. Hopefully this will be addressed in a future version of npm.
I also tried all of the above steps on my MAC Catalina, but didn't resolve my issue. These steps resolved my problem:
npm update
npx --ignore-existing create-react-app my-app
Thanks to this comment
This will work:
sudo chown -R 1000:1000 "~/.npm"
Neither force-cleaning the cache nor using chown worked for me, but deleting the folder did work and fixed the issue.
My error was:
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/aw/.npm"
The fix was to permanently erase the .npm folder in question, which I did using rm -rf:
sudo rm -rf /Users/aw/.npm
(Mandatory warning: this is a dangerous command if you typo it.)
I encountered the same issue and the problem with mine was that I was running an older version of npm. After updating npm and removing the .npmrc file, it worked just fine.
npm install -g npm#latest
rm .npmrc
Be careful before deleting the .npmrc file, take a backup as it will reset your npm configuration.
I fixed mine by running:
sudo npm cache clean --force
followed by removing the root owned files.
first, to view the file owners and group:
cd /Users/username/
ls -la
You have to check the owner of .npm, changed to non-root user:
sudo chown -R username:group "/Users/username/.npm"
or for global .npm-global
sudo chown -R username:group "/Users/username/.npm-global"
replace keyword: username/group accordingly
It helped me:
Remove and install npm again
It work for me now!
What I did? (I'm not saying it's the best way to fix this but i'ts working for me. I'm still looking for the best explications for this issue)
sudo rm -Rf /home/[YOUR_USER_NAME]/.npm-global/lib/node_modules/
and run your command again.
My explication is that it seems like something is corrupted in the node_modules's folder.
As it's not risky to delete it I did it and it works now.
Try sudo npx create-react-app example_app or in my case sudo npm install #vue/cli
I tried everything else here, but in the end realised that it might just be the command that I was running was not able to escalate the correct permissions.
Find error in your log file:
verbose Error: EACCES: permission denied, mkdir '/Users/xxx/.tnpm_tmp/npm-52731-e91f6671'
Use that error in your condition.
sudo chown -R 502:20 "/Users/XXX/.tnpm_tmp"
I solve the problem with the following commands
Install dependence > npm install create-react-app
run > create-react-app project_name
happy hack!!
Try to create your react app using yarn package manager.
I am getting this error while installing any JS package , I have done lots of search but no luck. So please let me know where i am making mistake.
npm ERR! request to https://registry.npmjs.org/node-modules failed,
reason: error:0906D06C:PEM routines:PEM_read_bio:no start line
WebServer : Apache2(xampp)
Node : v9.3.0
NPM : 5.5.1
I think that first you need to start prompt as an administrator, then run npm cache clean -f then try to run npm install, by this command the npm will install the packages listed in package.json.
Or
You can run npm config set registry http://registry.npmjs.org/ so you can run npm install -g node-modules. Read more in this answer.
I faced the same problem and finally I was able to solve the exact above error by doing the following steps:-
check version of your npm with npm -v
run npm -g install npm#<version> This step is important as npm is getting installed globally here.
Now run the command where you want to install something globally using npm. In my Case the command was npm install -g #angular/cli#6.2.9 which worked fine after these changes
If you are still facing the problem, I would recommend to follow the instructions about installing nodejs perfectly from here https://docs.npmjs.com/try-the-latest-stable-version-of-npm#upgrading-on-windows