3

We have the following package.json file:

{
  "name" : "DecisionsConsole",
  "version" : "0.0.0",
  "private" : true,
  "scripts" : {
    "start" : "node app.js"
  },
  "dependencies" : {
    "express" : "4.0.0",
    "cookie-parser" : "1.1.0",
    "serve-favicon" : "2.0.0",
    "morgan" : "1.1.1",
    "body-parser" : "1.3.0",
    "express-session" : "1.2.1",
    "errorhandler" : "1.0.1",
    "ejs" : "1.0.0",
    "request" : "2.34.0",
    "async" : "0.4.0",
    "lodash" : "2.4.1",
    "socket.io" : "1.0.4",
    "moment" : "~2.5.1",
    "pg" : "2.11.1",
    "connect" : "2.14.3",
    "sql" : "0.37.0",
    "request-json" : "0.4.10",
    "simplesets" : "1.2.0",
    "grunt" : "0.4.4",
    "aws-sdk" : "2.0.0-rc.19",
    "webworker-threads" : "0.4.13",
    "indexof" : "*",
    "serve-index" : "1.6.1",
    "node-rest-client" : "0.8.0",
    "querystring" : "0.2.0",
    "xml2js" : "0.4.6",
    "msexcel-builder" : "0.0.2",
    "mime" : "1.3.4"
  },
  "devDependencies" : {
    "grunt-contrib-compress" : "~0.7.0",
    "grunt-contrib-compass" : "~0.7.2",
    "grunt-contrib-uglify" : "*",
    "nodeunit" : "*"
  }
}

We are using AWS Elastic BeanStalk environment based on 64bit Amazon Linux 2014.02 v1.0.1 running Node.js . The reason it is an older environment, and not one of the latest versions is because there appear to be conflicts with between some of our packages and the newer AWS environment.

While deploying we get an error Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.

Upon further investigation, we find errors like this in the eb-tools.log :

 /bin/sh: pg_config: command not found gyp: Call to 'pg_config --libdir' returned 
 exit status 127. gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with 
 exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/opt/elasticbeanstalk/node-
 install/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/
 configure.js:337:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:
 98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:
 797:12) gyp ERR! System Linux 3.4.73-64.112.amzn1.x86_64 gyp ERR! command "node" "/
 opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/lib/node_modules/npm/
 node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /tmp/deployment/
 application/node_modules/pg gyp ERR! node -v v0.10.26 gyp ERR! node-gyp -v v0.12.2 
 gyp ERR! not ok > webworker-threads@0.4.13 install /tmp/deployment/application/
 node_modules/webworker-threads > node-gyp rebuild make: Entering directory `/tmp/
 deployment/application/node_modules/webworker-threads/build' CXX(target) Release/
 obj.target/WebWorkerThreads/src/WebWorkerThreads.o 

I realize it is a bit difficult to read, but it is all on one line in the eb-tools.log file. Upon some digging, I found this: Error installing node-gyp on ubuntu . However, i don't think it is related.

Upon further research, I found this: https://github.com/brianc/node-postgres/issues/684

It seems to make sense. The question is -- how do I get AWS Elastic BeanStalk to auto-install PG ?

Community
  • 1
  • 1
Oleg Dulin
  • 1,379
  • 4
  • 13
  • 23

3 Answers3

2

It shows that you don't have postgres installed on elastic beanstalk instance

  1. Create a .ebextensions folder from the root of your project.
  2. Create a file with package.config and the following

    packages: yum: postgresql93-devel: []

  3. Then commit your changes
  4. Lastly deploy to elastic beanstalk with eb deploy

Then you should be good.

Check out this link for more http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html

Solomon Ayoola
  • 2,639
  • 3
  • 18
  • 21
0

I had various problems deploying a Node+PostgreSQL application in Elastic Beanstalk. First I was getting the above mentioned message Update environment operation is complete, but with errors. For more information, see troubleshooting documentation, so I had to clean up my code a little bit: things that worked fine in my IDE (AWS's own Cloud9) did not work in EB. For instance, I had problems with bcrypt, that I had to replace it by bcrypt.js. Also, my package.json included Node among the dependencies, and triggered an error.

After getting a decent "eb create", the definitive answer were these instructions. Take your time to follow them, as the usual rushed trial and error is not likely to succeed. This is because the addition of the database adds some complexity, mainly due to security groups setup.

Here you will find a complete walkthrough of setting up a Node.js application with a PostgreSQL database (mentioned in the previous link). You have a github repository you can clone and do the installation yourself.

This video by AWS people is also useful to understand EB a little further.

Good luck!

RdC1965
  • 412
  • 5
  • 8
0

The accepted answer is giving the direct solution. thats good. But I highly recommend you run your nodejs app as docker inside elasticbeanstalk. that way, the application runs the same way in wherever you deploy Also you will find the build issues early and fix it.

Arun Kamalanathan
  • 8,107
  • 4
  • 23
  • 39