nodejs永远:启动应用程序
问题描述:
我正在运行我的网络应用程序npm start
,但现在我需要将其部署到数字海洋,这意味着我将不得不使用forever
启动我的应用程序,我无法弄清楚这一点.. 。nodejs永远:启动应用程序
我试图运行它forever npm start
但它返回:
error: Cannot start forever
error: script /root/saleseng/OP Apps Platform/server/npm does not exist.
这是我从package.json
scrips
对象:
"scripts": {
"start": "nodemon --watch src --exec babel-node -- src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
}
答
您将需要通过.js
文件永远的名字:
forever start src/index.js
这将启动脚本,直到永远。这可能与
forever logs scriptId -f
forever list
被监视会获取你的scriptId
UPDATE:
Transpiling到ES5
:
要使用babel
已经安装了以下相关:
"dependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
}
然后在你的项目的根目录创建一个.babelrc
具有如下:
{
"presets": ["es2015","stage-0"]
}
我们终于不用一个transpile,运行:
babel myInputDirectory --out-dir myOutputDirectory
试试这个 “永远启动-c” NPM启动“/ path/to/app/dir /” –
Found here:https://github.com/foreverjs/forever/issues/540#issuecomment-37762716 –