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.jsonscrips对象:

"scripts": { 
    "start": "nodemon --watch src --exec babel-node -- src/index.js", 
    "test": "echo \"Error: no test specified\" && exit 1" 
    } 
+0

试试这个 “永远启动-c” NPM启动“/ path/to/app/dir /” –

+0

Found here:https://github.com/foreverjs/forever/issues/540#issuecomment-37762716 –

您将需要通过.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 
+0

它显示了这个: 'data:[1] r2hU/usr/bin/nodejs src/index.js /root/.forever/r2hU.log STOPPED' – Valip

+0

这意味着您的脚本e没有遇到一些错误。当你运行'node yourfile.js'时会发生什么? –

+0

有没有办法看到这个错误? – Valip