Categories
JavaScript Answers

How to Fix the ‘nodemon command is not recognized in terminal for node js server’ Error with JavaScript?

Spread the love

Sometimes, when we want to run nodemon, we may get the ‘nodemon command is not recognized in terminal for node js server’ error with JavaScript.

In this article, we’ll look at how to fix ‘nodemon command is not recognized in terminal for node js server’ error with JavaScript.

Fix the ‘nodemon command is not recognized in terminal for node js server’ Error with JavaScript

To fix the ‘nodemon command is not recognized in terminal for node js server’ error, we can install nodemon locally or install it locally and add a script into package.json to run the local version.

To install it locally, we can run:

npm install -g nodemon

with NPM or:

yarn global add nodemon

with Yarn.

And to add a local version, we run:

npm install nodemon

with NPM or:

yarn add nodemon

with Yarn.

Then we add:

"serve": "nodemon server.js"

into the 'scripts' second of package.json .

And then we run:

npm run serve

With Yarn, adding to the 'scripts' section is optional, and we can just run:

yarn run nodemon server.js

If we did add the script to package.json , we run:

yarn run serve

Conclusion

To fix the ‘nodemon command is not recognized in terminal for node js server’ error, we can install nodemon locally or install it locally and add a script into package.json to run the local version.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.