'nodemon not working properly
I am running my nodejs app by npm start
I just installed nodemon by
sudo npm install -g nodemon so that i can get my server restarted when i save changes to files.
But when i try to start the server, something like this
nodemon ./app.js localhost 3000 or nodemon start localhost 3000
I get this as output
LM-SJC-00871929:webapp gdeep$ nodemon ./app.js localhost 3000
28 May 23:34:30 - [nodemon] v1.1.1
28 May 23:34:30 - [nodemon] to restart at any time, enter `rs`
28 May 23:34:30 - [nodemon] watching: *.*
28 May 23:34:30 - [nodemon] starting `node ./app.js localhost 3000`
but when i go to my webpage, i get
Oops! Google Chrome could not connect to localhost:3000. What am i doing wrong?
App.js here http://collabedit.com/t35dy
Solution 1:[1]
Here's what I did to make nodemon update correctly:
nodemon index.js -L
The -L flag stands for legacyWatch, here's an explanation from the official doc:
In some networked environments (such as a container running nodemon reading across a mounted drive), you will need to use the legacyWatch: true which enables Chokidar's polling.
https://www.npmjs.com/package/nodemon#application-isnt-restarting
Solution 2:[2]
In my case, I had to install nodemon globally. Use this command to do so..
npm install -g nodemon
If you're using Linux you may need to prefix the command with the sudo keyword for administration access..
sudo npm install -g nodemon
Solution 3:[3]
try running nodemon ./app.js 3000 or nodemon start 3000
Solution 4:[4]
For Express.js 4,
use nodemon
or
nodemon bin/www
Solution 5:[5]
Add following code in your code
app.jsapp.listen(3000, function(){ console.log("info",'Server is running at port : ' + 3000); });package.jsonnodemon app.js
Then run npm start from the command line.
Solution 6:[6]
npm i nodemon- Edit your
Package.jsonfile:- set start tonodemon:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js"
}
- Run
npm startto try the server
Solution 7:[7]
If you are using express4, the easiest way is to navigate to package.json and change
"scripts": {
"start": "node ./bin/www"
}
to
"scripts": {
"start": "nodemon ./bin/www"
}
Solution 8:[8]
For Express 4; Just run
nodemon
command (with out any args) on the directory; this works for me.
Solution 9:[9]
You might also run into the issue of having an empty .nodemonignore.
Solution 10:[10]
thanks you need to type this after to enter in the folder application with
cd your_project_folder
sudo nodemon bin/www
Solution 11:[11]
try
npm install --save-dev nodemon
and then
in
package.json file
keep like this
"scripts": {
"start": "nodemon",
"test": "echo \"Error: no test specified\" && exit 1"
},
instead of npx nodemon, which takes more time
Solution 12:[12]
Certain child processes related to your parent process may not be closed. Try to kill all the child processes.
Solution 13:[13]
Use single quotation for multi-value args like `--exec'.
e.g. I changed "nodemon --exec yarn build-langs" to "nodemon --exec 'yarn build-langs'" and worked.
Solution 14:[14]
"scripts": {
"start": "nodemon app.js"
},
check it, if it's true or not
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
