admin管理员组文章数量:1312791
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:
- adding the 4.1.2 source to my .ebextensions config file and then updating the reference in
/tmp/deployment/config/#etc#init#nodejs.conf
butconsole.log(process.argv)
was still 0.12.6. What's more, the second time I run this I get sometext file busy
error presumably because it's trying to change the source of the node package while node is still running... (see .jspa?threadID=169385) - adding a file that downloads the 4.1.2 source and ungzips it and updates the reference like in but this didn't seem to work either (version still 0.12.6)
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?
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:
- adding the 4.1.2 source to my .ebextensions config file and then updating the reference in
/tmp/deployment/config/#etc#init#nodejs.conf
butconsole.log(process.argv)
was still 0.12.6. What's more, the second time I run this I get sometext 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./thread.jspa?threadID=169385) - adding a file that downloads the 4.1.2 source and ungzips it and updates the reference like in https://github./kopurando/better-faster-elastic-beanstalk but this didn't seem to work either (version still 0.12.6)
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?
Share Improve this question edited Mar 12, 2016 at 1:41 Clarkie 7,5509 gold badges40 silver badges53 bronze badges asked Oct 7, 2015 at 0:04 Andrew RasmussenAndrew Rasmussen 15.1k10 gold badges47 silver badges84 bronze badges2 Answers
Reset to default 11Instead of using node v4, you can use babel to pile 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 pile 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./babel/example-node-server
babel home page: https://babeljs.io/
One option is to create a custom AMI (Amazon Machine Image) and use that to deploy your app:
http://docs.aws.amazon./elasticbeanstalk/latest/dg/using-features.customenv.html
There's loads of steps in their documentation but in simple terms you need to:
- spin up a server
- customise the installations however you wish
- create an image
- create an elastic beanstalk environment using your newly created AMI
Another option if you want to run node with ES2015 features is to use the babel cli.
You'll need to add a start
task to your package.json
:
{
"scripts": {
"start": "babel-node index.js",
},
"dependencies": {
"babel": "^5.8.23",
}
}
However...
Not meant for production use
You should not be using babel-node in production. It is unnecessarily heavy, with high memory usage due to the cache being stored in memory. You will also always experience a startup performance penalty as the entire app needs to be piled on the fly.
本文标签: javascriptElastic Beanstalk and ES6Stack Overflow
版权声明:本文标题:javascript - Elastic Beanstalk and ES6 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741908619a2404302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论