using forever module for windows in nodejs

情到浓时终转凉″ 提交于 2020-01-02 00:59:12

问题


I downloaded forever module from the following link

https://github.com/nodejitsu/forever

I extracted the zip file and placed it in my node_modules folder. and from my command prompt went into the node js path and gave

forever filename.js as instructed.But i received the error as below

C:\Users\290495\Desktop\newnode\Manoj\Node\nodejs>forever testing.js
'forever' is not recognized as an internal or external command,
operable program or batch file.

Don't know where i am goin wrong.Anyhelp will be much appreciated


回答1:


Forever needs to be installed globally. Install it with the -g flag i.e. npm install forever -g




回答2:


Correct syntax is forever start app.js, but for some reason it doesn't work on Windows. No error message, but the application doesn't run.




回答3:


There was a bug in forever (on windows). Forever-win is a windows compatible version for it. Try below commands on windows command prompt, hopefully you should be able to run it successfully.

Install 'forever' and 'forever-win' globally

npm -g install forever
npm -g install forever-win

Start app using forever

cd <<project directory>>
forever start <<app.js>>



回答4:


To build on top of @richmb's answer. You can install it locally and then add it as a npm script in your package.json :

"scripts": {
    "forever" : "forever"
  },

Then , you can call it with npm run forever

Example :

npm run forever start app.js

npm run forever list

etc..




回答5:


To use it locally.

npm install forever
./node_modules/forever/bin/forever start <<app.js>>


来源:https://stackoverflow.com/questions/14251451/using-forever-module-for-windows-in-nodejs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!