I have generated express application with express-generator
,everything works fine until i deleted the node_modules
folder.
after reinstall the node-modules nodemon
is not starting the application.
[nodemon] starting
node app.js
[nodemon] clean exit - waiting for changes before restart
Here is the package.json file
{
"name": "testapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"build": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"cors": "^2.8.4",
"csurf": "^1.9.0",
"debug": "~2.6.9",
"express": "~4.15.5",
"express-session": "^1.15.6",
"jade": "~1.11.0",
"morgan": "~1.9.0",
"serve-favicon": "~2.4.5"
},
"main": "app.js",
}
I have generated express application with express-generator
,everything works fine until i deleted the node_modules
folder.
after reinstall the node-modules nodemon
is not starting the application.
[nodemon] starting
node app.js
[nodemon] clean exit - waiting for changes before restart
Here is the package.json file
{
"name": "testapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"build": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"cors": "^2.8.4",
"csurf": "^1.9.0",
"debug": "~2.6.9",
"express": "~4.15.5",
"express-session": "^1.15.6",
"jade": "~1.11.0",
"morgan": "~1.9.0",
"serve-favicon": "~2.4.5"
},
"main": "app.js",
}
Share
Improve this question
asked Feb 27, 2018 at 4:52
shamon shamsudeenshamon shamsudeen
5,85820 gold badges74 silver badges144 bronze badges
7
- possibilities are your other code file contains issue in code. or try deleting package lock json then try to run it – harsh zalavadiya Commented Feb 27, 2018 at 4:55
-
deleted
package-lock.json
but still the same – shamon shamsudeen Commented Feb 27, 2018 at 4:58 - can you put reproducable sample code in git repo and send so it will be better to analyse the root cause – harsh zalavadiya Commented Feb 27, 2018 at 5:00
- here is the github repo github./Shamonshamonsha/jenkins-test – shamon shamsudeen Commented Feb 27, 2018 at 5:02
- @harshzalavadiya have found the issue? – shamon shamsudeen Commented Feb 27, 2018 at 5:13
2 Answers
Reset to default 3This is not an issue of nodemon, this error occurs when the file you are running with nodemon is ended its execution(i.e. scripts that do not run continuously).
I have cloned your repo and working fine for me so you should be running nodemon app.js
.
If you are generating app with express generator your app.js is not the file that listens to the server. Actually, bin/www
file is the one that starts listening and the app only create server object.
So nodemon ./bin/www
should do the trick for you.
you can also edit package.json and add following in the code
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www"
}
And then run npm run dev
.
you can modify your package.json and make it running.
"scripts": {
"start": "node ./bin/www",
"build": "nodemon ./bin/www"
},
and then you can run your app normally with
npm build
because nodemon generally executes the npm start
mand and starts watching your files when you run nodemon
but from express 4 running node app.js
doesn't seems to be working anymore
you can modify package.json build mand but don't modify start mand because when you are deploying it to the production generally it will execute npm start
and as production environment generally won't be having nodemon