1

i have tried all the three one by one by installing them globally. but none seems to work. I am using these to restart the server automatically when i make any changes.

Following are the commands that i am using.

nodemon npm start

forever npm start

supervisor npm start

Error from supervisor

Error: Cannot find module 'E:\d v\MEAN Lynda - Developing for the MEAN Stack and
 MongoDB\projects\project\start'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3
 Program node start exited with code 1

Starting child process with 'node start'
module.js:341
    throw err;
    ^

Error from forever

E:\d v\MEAN Lynda - Developing for the MEAN Stack and MongoDB\projects\project>f
orever npm start
warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up f
or at least 1000ms
error:   Cannot start forever
error:   script E:\d v\MEAN Lynda - Developing for the MEAN Stack and MongoDB\pr
ojects\project\npm does not exist.
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Ankur Marwaha
  • 1,613
  • 2
  • 15
  • 30
  • can you provide more informations? errors given, alerts, strange behavior of these commands, etc. – rEDSAMK Jul 11 '16 at 18:20

1 Answers1

1

you should check the package.json file where you have properly assigned the value of "start" key or not. Forever and supervisor are used as follows. you can always type and check that using :

forever -h
supervisor -h

you will find the following output as examples of using supervisor:

Examples:
supervisor myapp.js
supervisor myapp.coffee
supervisor -w scripts -e myext -x myrunner myapp
supervisor -- server.js -h host -p port

forever is used as follows:

forever start app.js
rresol
  • 323
  • 4
  • 20
  • "scripts": { "start": "node ./bin/www" } If i use npm start as it is, it works – Ankur Marwaha Jul 12 '16 at 03:59
  • https://github.com/foreverjs/forever/issues/540 This is an issue over here. What you can do according to the solution described there is use "start": "npm run build && forever start --minUptime 1000 --spinSleepTime 1000 server.js" and then try . you can check the link for reference. – rresol Jul 12 '16 at 05:36
  • According to your suggestion, I am trying to use this command -- "start": "node ./bin/www && forever start --minUptime 1000 --spinSleepTime 1000 server.js" -- it runs the just the server and doesn't do what is expected from forever. By the way, what is server.js over there. – Ankur Marwaha Jul 13 '16 at 18:38