I'm uploading a node.js file via elastic beamstalk CLI. I'm using the sample given to me be AWS.
var http = require("http");
var AWS = require('aws-sdk');
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello Worlds");
response.end();
}).listen(process.env.PORT || 8888);
Everything works fine until I include the:
var AWS = require('aws-sdk');
Then I get this error message.
502 Bad Gateway
nginx/1.4.7
How do I fix this? I'm only uploading one file, server.js to beanstalk. Thanks
Can you ssh to the instance and see the logs in /var/log/nodejs/nodejs.log? I suspect you will need a package.json that installs aws-sdk as a dependency. Do you already have that?
Update 05/26:
I tried the following app. Below are the contents of various files in the app source zip.
package.json
{
"dependencies": {
"aws-sdk": "*"
}
}
server.js
var http = require("http");
var AWS = require('aws-sdk');
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello Worlds");
response.end();
}).listen(process.env.PORT || 8888);
.ebextensions/01-setup.config
option_settings
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeVersion
value: 0.10.26
I am using Solution Stack "64bit Amazon Linux 2014.03 v1.0.2 running Node.js" and the app with the above contents launches successfully. Can you try looking at both files /var/log/node/nodejs.log and /var/log/npm-debug.log?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.