-1

I am trying to automate the server reload using the nodemon. I have it installed locally and have the start set to

nodemon app.js using the code:

"scripts": { "start": "nodemon app.js" }

It ran fine for the first time, but after shutting down the system once and reopening my project, it does not seem to run properly anymore. Now it throws an error every time I use the command nodemon app.js.

The error line is:

nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

error line shown in VS Code terminal

Aniruddha
  • 774
  • 1
  • 7
  • 18
  • 3
    Have you installed it globally with `npm i -g nodemon`? – Anurag Srivastava Mar 28 '20 at 09:19
  • 1
    You either have to install it globally as @AnuragSrivastava stated or you need to give the full path of executable. Or it has to be in path of Environmental Variables. – Eldar Mar 28 '20 at 09:20
  • try to delete the node modules folders and reinstall them again. try installing global nodemon globally to see if the error persist. – ionut-t Mar 28 '20 at 09:21
  • 1
    you want to write `npm start` in the integrated terminal that should run the `start` script – Abdullah Abid Mar 28 '20 at 09:29
  • If you are in Linux you have to be in an admin account, i.e. with root privileges, to install globally. When you do this you will find npm package commands are already on the $PATH environmental variable. But if you just want nodemon locally from your standard user account, e.g. to test-run a Node.js web app locally, then you have to add the location of the nodemon executable to the $PATH. If your web app is in a folder called *nodeapp* on your desktop, then add this line to your /home//.profile: *PATH="$HOME/desktop/nodeapp/node_modules/.bin:$PATH"* – Trunk Feb 24 '21 at 19:53

1 Answers1

3

The best solution I could go about this is:

 npm install -D nodemon // install as a dev dependency

 npm start // run script start

Ezrqn Kemboi
  • 897
  • 1
  • 12
  • 19