I have a problem: nodemon does not run off the npm script (e.g. npm start
),
but if nodemon is called on the command line outside the npm script, nodemon runs as normal.
$ nodemon server.js
14 Feb 22:59:51 - [nodemon] v1.3.7
14 Feb 22:59:51 - [nodemon] to restart at any time, enter `rs`
14 Feb 22:59:51 - [nodemon] watching: *.*
14 Feb 22:59:51 - [nodemon] starting `node server.js`
How it is called in npm script:
package.json
{
...
"scripts": {
"start": "nodemon server.js"
}
}
When npm start script is run:
$ npm start
> aaa@0.0.1 start /home/akul/Documents/aaa
> nodemon server.js
sh: 1: nodemon: not found
npm ERR! Linux 3.13.0-45-generic
npm ERR! argv "node" "/home/akul/npm-global/bin/npm" "start"
npm ERR! node v0.12.0
npm ERR! npm v2.5.0
npm ERR! code ELIFECYCLE
npm ERR! aaa@0.0.1 start: `nodemon server.js`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the aaa@0.0.1 start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the aaa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls aaa
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/akul/Documents/aaa/npm-debug.log
I've been looking for a solution, but have not found one.
I had this problem and even after I have used the command
npm install nodemon --save
in my application, I still had problem with nodemon.I just resolved after I installed nodemon globally, using the command:
npm install nodemon -g
You can resolve this problem by adding nodemon to you package.json
The problem happens when nodemon does not exist in /node_modules/.bin
Try to install nodemon globally.
Had the same problem otherwise was just working fine a day ago. Very simple fix first check if nodemon exists on your system globally or not
If you don't see then install it
npm install -g nodemon
(g stands for globally)If you see it still doesn't work then you need to configure environment variable I use Windows OS. On Windows navigate to
Now check if you have this PATH
C:\Users\yourUsername\AppData\Roaming\npm
If not, you will see some existing paths, just append to it separating with semicolon. That's it! Worked for me. For me node was installed in C:..\Roaming\npm and for you if the PATH is different, you will put in whatever applcable.
Here's how I fixed it :
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 :-Here "npm" is the path to my global npm packages . Replace it with the global path in your system
under your current project directory, run
then under "scripts" in your package.json file, add "start": "nodemon app.js" (or whatever your entry point is)
so it looks like this:
and then run
That avoids complicate PATH settings and it works on my mac
hope can help you ;)