I have been using nodemon for past few months now. It's just that today I got this error. I tried uninstalling nodemon and the reinstalled it. I also forced install it. Nothing worked. Whenever I run the nodemon command
bash: nodemon: command not found
pops up.
There are other answers too and I have looked them all up. They haven't worked for me.
I have faced this error once, and in my package.json, I updated the nodemon location and it worked.
Below code is in my package.json
"start" : "./node_modules/.bin/nodemon server.js"
and then after running npm start it works.
If you don't have nodemon installed globally try to do that.
I had the same issue but after installing it globally whenever I ran the command it work
sudo npm install -g nodemon
I hope this will help
This is down to your global variables.
Ensure npm is included in your PATH var and there is no conflicting npm directories
echo %PATH%
If it is, get your npm root, Ensure the npm in your global path matches the npm root
npm root -g
Navigate there and ensure the "nodemon" file is there. This is where all the npm install -g files are installed.
If not run npm i nodemon -g and confirm that it has been added to the npm root folder.
Having all of these boxes ticked will get these globals are working for you again.
Related
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 installed npm-run-all and also configured the environment variable (which may or may not be not required) on my Windows machine but am getting an error:
'npm-run-all' is not recognized as an internal or external command,
operable program or batch file
I am trying to build my current project with npm run build which includes the script where the error is thrown:
npm-run-all -p build-css build-webpack
Do I have to do any additional things to make it run?
Make sure the npm-run-all is in your package.json devDependencies.
If npm-run-all is present in your package.json, run npm i
If not present install it, run: npm i npm-run-all -D
If error is still present, follow these steps:
Remove node_modules folder: run rm -rf node_modules
Install all dependecies: run npm i
Hope this helps!
You may just need to run the following command first (from the directory with the package.json file)
npm install
Please do that like this.
npm i npm-run-all -g
And then this issue will be fixed.
You have a couple of options here, besides installing npm-run-all as a global package as suggested by #Vaibhav in the comments:
1) Create an NPM script
The package.json file has a scripts section which can used to define shortcuts for anything you need to run while you're working on your app. There are some pre-defined scripts, like run or test than can be executed with simply npm start/npm test or you can define anything you like and then run it with npm run my-script-name. You could try:
{
"scripts": {
"start": "npm-run-all -p build-css build-webpack"
}
}
Any NPM module referenced here "just works" (i.e. the path to the executable is resolved under the hood by NPM)
2) NPX
In newer versions of NPM (i.e. >= 5.2 or so), the "NPX" executable is provided. This has a similar effect to running commands inside an NPM script. You would run:
npx npm-run-all -p build-css build-webpack
Again, the path would be automatically resolved.
If you have an older NPM install, you can also install it separately:
npm install -g npx
npm install -g npm-run-all
Works for me.
Double check if npm-run-all is in your package.json devDependencies.
I had same problem while using code editor Brackets.
To resolve the error, I did the following steps.
Add nodejs new system variable to your PC under Control Panel -> System -> Advanced System Settings
;C:\Program Files\nodejs\
After that, re-run command:
npm
I don't know if this would help anyone, but I got this error because I was doing nodemon server.js instead of nodemon server/server.js. I wasn't in the right folder!
Did you reopen the terminal after you installed node?
If you have installed npm with the current terminal window open. Your terminal window will not have loaded the latest path settings (with npm location) to find the npm application to run the command. In this case try below steps .
Try closing the current terminal session.
Reopen a new session.
Try the command again ( will pick up the new path settings with npm installed)
This worked for me.
npm audit fix --force
Also you can try downgrading your autoprefixer, seems version 10.0.0 doesn't work well with postcss
npm i autoprefixer#9.8.6
I have installed mean.io and ran sudo npm install. Actually following commands in sequence
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
sudo npm install
It is supposed to download and install angularjs libraries into public/system/lib. After doing the above steps public /system/lib is not created due to which when I start the application I get the error
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp/public/system/lib/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
Is it something to do with certain npm/angularjs server being down. I have faced this problem earlier also but got fixed on 2nd try and I didn't bother to do more research. This became a big issue when I try to pull my repo into cloud and start the application. public/system/lib is added in .gitignore by default and is expected to be created during npm install.
I get following warnings with sudo npm install
npm WARN package.json mean-connect-mongo#0.4.3 No repository field.
npm WARN cannot run in wd mean#0.3.3 node node_modules/bower/bin/bower install (wd=/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp)
this is link to package.json
The problem maybe related to running npm install as sudo, which can cause problems. As mentioned in another stack overflow question, this can be worked around in a couple ways. But because it looks like this is being run from your home directory, you really shouldn't need to run npm install as root.
Try to issue the same commands, but the last without sudo:
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
npm install
Note that the reason you may need to run npm install -g <package> using sudo is because by default npm uses /usr/local for global installs, which can be a restricted directory. However, when you install a package locally (without the -g flag) you should not need to run as root.