9

nodemon always worked for me. I always did nodemon server and it would run the server file and watch for updates and node would restart. But now when I do it, I get this in the cmd (I use windows):

Usage: nodemon [nodemon options] [script.js] [args]

See "nodemon --help" for more.

I tried uninstalling and reinstalling nodemon globally but still get the feedback. now I have to restart the server with regular node on every update.

EDIT:: This is what it looke like when i type in dir and press enter

05/29/2016  05:55 PM    <DIR>          .
05/29/2016  05:55 PM    <DIR>          ..
05/29/2016  05:35 AM    <DIR>          node_modules
05/29/2016  02:20 PM    <DIR>          public
05/24/2016  09:30 PM             2,836 server.js
05/29/2016  12:05 AM             3,513 server2.js
05/30/2016  12:41 AM             3,651 server3.js
05/29/2016  05:55 PM    <DIR>          views
               3 File(s)         10,000 bytes
               5 Dir(s)  650,802,348,032 bytes free
jack blank
  • 5,073
  • 7
  • 41
  • 73
  • Do you have `nodemon` installed locally in your project? From your project folder, run `npm list --depth=0` on the command line. It will give you a list of the modules installed in your project based on the contents of the `node_modules` folder. – Neil T. May 31 '16 at 04:58

7 Answers7

17

Are you sure your server file is in the folder you are in? Run dir and make sure the file you expect is in the directory before running the command. If the file you are trying to run is not present in the current directory, nodemon will spit out the usage message.

If your file is in the directory, try executing with the full file extension -- nodemon server.js

xianwill
  • 523
  • 3
  • 9
  • Hi, thanks for the answer. It looks like the server file is in the directory I'm working in. I edited the question to show the output of the `dir` command. What do you think. – jack blank May 31 '16 at 04:51
  • Yes, I agree -- try executing with the file extension included in the command `nodemon server.js` – xianwill May 31 '16 at 05:01
0

Make sure that when you are running the command nodemon server.js then you are inside the same directory in which your server file is. This was the error that I was making while running the command it only appears when the nodemon is unable to find the file which it has been told to run after every save.

0

make sure you are running nodemon command in that particular directory else,you need to check the directory first wheather you are into it or not ,or cd thatDirectory ,and then run the nodemon index.js

0

Make sure there is a node_modules folder in your project directory. If it's not there ,kindly install the folder with this command - npm install

Famo
  • 1
0

**one of the two important reasons of that error are 1.You have not installed npm packages in right directory. 2.U r running ur server in wrong directory or wrong folder. **

0

Just ensure you are in the right directory where the nodemon package was installed. That should resolve the issue

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '23 at 04:24
0

In addition to what already written in the accepted answer, make sure that you are pointing to an existing file. In my case, I did in the scripts section:

"dev": "NODE_ENV=local nodemon --watch src --ext js,yaml,json,ejs --ignore *.test.js --exec node --es-module-specifier-resolution=node --inspect ./src/bin/www.js --source-maps DEBUG=metrics",

But the ./src/bin/www.js file wasn't found.

Or Assayag
  • 5,662
  • 13
  • 57
  • 93