I'm trying to deploy my node server on Elastic Beanstalk but it won't work because the latest version Elastic Beanstalk supports out of the box is 0.12.6 (July 2015). Using either io.js or the latest node version (4.1.2) are both viable options but it isn't clear how to get the ec2 instances spun up by beanstalk to do this.
I've tried a bunch of stuff including:
/tmp/deployment/config/#etc#init#nodejs.conf
but console.log(process.argv)
was still 0.12.6. What's more, the second time I run this I get some text file busy
error presumably because it's trying to change the source of the node package while node is still running... (see https://forums.aws.amazon.com/thread.jspa?threadID=169385)Why is it so hard to just run the latest stable version of node and something that has been widely supported for 4 months on AWS?
Instead of using node v4, you can use babel to compile es6 code to es5 code and deploy es5 code to the beanstalk.
Let's say all your source codes are in lib
directory with index.js
file which start the server.
lib/
index.js
other
Then you can use babel lib -d dist
to compile es6 files in lib
directory and create es5 version of the files in dist
directory.
dist/
index.js
other
Then you can just node dist/index.js
to run your server and only need to change package.json
as below for beanstalk since beanstalk uses npm start
to run your server
"scripts": {
"start": "node dist/index.js"
}
I like to use babel for es6 since it has more coverage on new features. You can find more information
node.js server example: https://github.com/babel/example-node-server
babel home page: https://babeljs.io/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With