I\'m on a Mac running El Capitan. I have node v5.6.0 and npm v3.6.0. When I try to run nodemon, I get:
-bash: nodemon: command not found
I th
I ran into the same problem since I had changed my global path of npm packages before.
When I installed nodemon using : npm install nodemon -g --save
, my path for the global npm packages was not present in the PATH variable .
If you just add it to the $PATH variable it will get fixed.
Edit the ~/.bashrc
file in your home folder and add this line :-
export PATH=$PATH:~/npm
Here "npm" is the path to my global npm packages . Replace it with the global path in your system
Just in case for those using Windows, you don't need sudo
npm i -g nodemon
FOR WINDOW USERS
I tried every possible way but nothing worked for me.
What worked was:- npx nodemon server
FOLLOWING WILL BE THE OUTPUT:-
If you want to run it locally instead of globally, you can run it from your node_modules:
npx nodemon
Make sure you own root directory for npm so you don't get any errors when you install global packages without using sudo.
procedures:- in root directory
sudo chown -R yourUsername /usr/local/lib/node_modules
sudo chown -R yourUsername /usr/local/bin/
sudo chown -R yourUsername /usr/local/share/
So now with
npm i npm -g
you get no errors and no use of sudo here. but if you still get errors confirm node_modules is owned again
/usr/local/lib/
and make sure you own everything
ls -la
now
npm i -g nodemon
will work!
npx nodemon filename.js
This will work on macOS BigSur