问题
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