I am using the nodemon
package, but it is not restarting the server. It is only showing "restarting due to changes". But in youtube videos, I saw that it was showing "server running" status after that.
In my case, that was not showing. It simply shows "restarting due to changes", my work also does not update when I view it in a browser.
I read lots of related stack overflow questions but none of them helped me ... Installing them locally on my project as devdependent.noting also does not work.
I also tried changing the script tags in the package.json
file.
While running, I used nodemon
, npm start
, nodemon app.js
, nodemon lib/dev-server.js --delay 1
, nodemon -L
, and many more, but nothing helped.
================================================================================= edited question:
i am using vs code. trying to run my javascript code with express framework .
i am using git bash terminal. whatever basic hello world code also cannot run with nodemon.
the steps i have followed:
node -v
and npm -v
is working on my bash terminal.
i have created a basic hello world express app . using npm init
npm install express --save
i am attaching my github repository of this testApp .git
then the main problem is about nodemon..
installing nodemon: npm install nodemon --save-dev
,also nodemon install -g
in script tag : "scripts": { "start": "node app.js" },
code for running nodemon: nodemon app.js
in my terminal while running this i am getting:
(bash: nodemon: mand not found)
but node app.js
is working....
then using npx nodemon app.js
it was showing-----
([nodemon] 2.0.4 [nodemon] to restart at any time, enter
rs[nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting
node app.js Example app listening at http://localhost:3000 [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes.)
you can clearly see on first time it was listening to port but on next times when i do any changes it showing restarting. but not restarting..
before when i am posting this this was the case for using nodemon
normally but now nodemon
is not working ...
i am attaching my system environment variable path: C:\Program Files\MongoDB\Server\4.2\bin;C:\Program Files\Git\cmd; C:\Program Files\nodejs; C:\Program Files\nodejs\node_modules\npm
i am giving link for my vs code screenshots .jpg .jpg
I am using the nodemon
package, but it is not restarting the server. It is only showing "restarting due to changes". But in youtube videos, I saw that it was showing "server running" status after that.
In my case, that was not showing. It simply shows "restarting due to changes", my work also does not update when I view it in a browser.
I read lots of related stack overflow questions but none of them helped me ... Installing them locally on my project as devdependent.noting also does not work.
I also tried changing the script tags in the package.json
file.
While running, I used nodemon
, npm start
, nodemon app.js
, nodemon lib/dev-server.js --delay 1
, nodemon -L
, and many more, but nothing helped.
================================================================================= edited question:
i am using vs code. trying to run my javascript code with express framework .
i am using git bash terminal. whatever basic hello world code also cannot run with nodemon.
the steps i have followed:
node -v
and npm -v
is working on my bash terminal.
i have created a basic hello world express app . using npm init
npm install express --save
i am attaching my github repository of this testApp https://github./webdevshiv/testApp.git
then the main problem is about nodemon..
installing nodemon: npm install nodemon --save-dev
,also nodemon install -g
in script tag : "scripts": { "start": "node app.js" },
code for running nodemon: nodemon app.js
in my terminal while running this i am getting:
(bash: nodemon: mand not found)
but node app.js
is working....
then using npx nodemon app.js
it was showing-----
([nodemon] 2.0.4 [nodemon] to restart at any time, enter
rs[nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting
node app.js Example app listening at http://localhost:3000 [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes.)
you can clearly see on first time it was listening to port but on next times when i do any changes it showing restarting. but not restarting..
before when i am posting this this was the case for using nodemon
normally but now nodemon
is not working ...
i am attaching my system environment variable path: C:\Program Files\MongoDB\Server\4.2\bin;C:\Program Files\Git\cmd; C:\Program Files\nodejs; C:\Program Files\nodejs\node_modules\npm
i am giving link for my vs code screenshots https://i.sstatic/7cslK.jpg https://i.sstatic/HaFOf.jpg
Share Improve this question edited Jun 29, 2020 at 19:58 Ragul Shiv asked Jun 28, 2020 at 9:36 Ragul ShivRagul Shiv 211 silver badge3 bronze badges 7- The question could be improved if you could add more information how to replicate the behavior you are observing. Whats the exact CLI mand you are running? How does you package.json look. Maybe a demo setup on github? – perelin Commented Jun 28, 2020 at 20:51
- Actually i dont know adding files on github!.. morever whichever basic codes also not working!.. stackoverflow not allowing me to share screenshots!. If u never mind can you give me your gmail id.. so i can send you!.. i am new to here!. I have got no help!.. i was stuck here.. please mind helping me!.. – Ragul Shiv Commented Jun 29, 2020 at 14:43
- Hi Ragul, just use some image sharing service like imgur. to upload images and share the link in your question. A good addition would also be: what server are you working on? Express?Have you checked out that guide: alligator.io/workflow/nodemon ? If it doesn´t help please provide a demo project on github that replicates the behaviour and poste the relevant code snippets here. – perelin Commented Jun 29, 2020 at 15:50
- 1 sir, i really put lot of effort and time in creating this question.. i have updated that.question and attached github repository and images too! – Ragul Shiv Commented Jun 29, 2020 at 19:56
- 1 try only nodemon app.js – Adeel Commented Jun 29, 2020 at 19:57
4 Answers
Reset to default 4Try adding the path of your system 32 ( in my case 'C:\Windows\System32'
) to environment variables.
It worked for me
$npm ls chokidar
run the above mand in the directory you have nodemon installed. This worked for me.
The advice from @Adeel is pletely correct. This is how I tested the solution:
Clone your demo repository, enter the directory and install dependencies
$ git clone https://github./webdevshiv/testApp.git
$ cd testApp
$ npm install
Install nodemon (as described by you and the nodemon website [1])
$ npm install -g nodemon
Use nodemon as described on their website
Just use nodemon instead of node to run your code...
In our case that would be (as @Adeel suggested)
$ nodemon app.js
For me this starts nodemon with the following output:
$ nodemon app.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
Example app listening at http://localhost:3000
When I change anything in app.js now nodemon reloads the express server automatically.
To further improve the setup you could replace the start script in package.json
so it looks like this:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
Now you can just use $ npm start
to run nodemon.
[1] https://nodemon.io/
Hey don't use nodemon.
Solution:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node --watch app.js },