Sometimes, when we want to run nodemon, we may get the ‘nodemon command is not recognized in terminal for node js server’ error in Node.js.
In this article, we’ll look at how to fix ‘nodemon command is not recognized in terminal for node js server’ error in Node.js.
Fix the ‘nodemon command is not recognized in terminal for node js server’ Error in Node.js
To fix the ‘nodemon command is not recognized in terminal for node js server’ error in Node.js, 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.