How do I modify the node startup command in Open Shift?

这一生的挚爱 提交于 2020-01-04 06:52:49

问题


I'm using ES6 with babel-node to create my app and I require my app to start with the command babel-node app.js. This command is listed in scripts: start in my package.json so the command npm start runs the correct command.

Open shift starts node apps with node + what ever script is set in the main property of your package.json file. In my case its "main": "app.js". So this command is run node app.js.

The server is choking on the first ES6 it encounters which makes sense. I can't figure out how to configure openshift to run babel-node or npm start to start up my app.

Here is my package.json file -> https://gist.github.com/jkinman/2cc57ce5fae5817d6bca


回答1:


You shouldn't run your server with babel-node, which is memory intensive and not meant for production. Instead, you should use the require hook by creating a file start.js (name unimportant) with the following content:

require('babel-core/register')
require('./app.js')
// or server.js or whatever you use to normally start you app

Then you can start your server with node start.js.



来源:https://stackoverflow.com/questions/33636804/how-do-i-modify-the-node-startup-command-in-open-shift

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