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.
Install
nodemon
globally using following command. It works on my computer, and I'm sure it will work on your system also.Sometimes you should have the permission to install it globally. It can be easily done by using following command.
In LINUX UBUNTU:
sudo npm install nodemon -g --save
In Fedora:
a)
su
b)
npm install nodemon -g --save
Try to check installed global packages
npm list -g --depth=0
. If you will not findnodemon
, - install it with flag-g
or--save-dev
. Don't installnodemon
with flag--save
, becausenodemon
uses only fordevelopment
.I wanted to add how I fixed this issue, as I had to do a bit of mix and match from a few different solutions. For reference this is for a Windows 10 PC, nodemon had worked perfectly for months and then suddenly the command was not found unless run locally with npx. Here were my steps -
npm list -g --depth=0
, in my case it was installed, so to start fresh...npm uninstall -g nodemon
npm install -g --force nodemon --save-dev
(it might be recommended to try runningnpm install -g nodemon --save-dev
first, go through the rest of the steps, and if it doesn't work go through steps 2 & 3 again using --force).npm config get prefix
, which in my case was located at C:\Users\username\AppData\Roaming\npmexport PATH=%PATH%;C:\Users\username\AppData\Roaming\npm;
(Obviously replace "username" with whatever your username is, or whatever the file path was that was retrieved in step 4)I hope this helps anyone who has been struggling with this issue for as long as I have!
You can always reinstall Node.js. When I had this problem, I couldn't fix it, but all I did was update the current version of Node. You can update it with this link: https://nodejs.org/en/download/