Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does AWS Beanstalk use NPM when deploying a Nodejs App?

Tags:

I'm curious about the overall workflow of an AWS Beanstalk deployment. I'm assuming it runs npm at some point to get the packages installed on the server(s). But I was just wondering if AWS Beanstalk uses the latest command of 'npm install --production' to install packages. Currently I have a packages.json file as shown below and would like to insure if possible that only the dependencies are being installed and not the devDependencies.

"dependencies": {   "express": "3.4.4",   "jade": "*",   "restify": "~2.6.0",   "assert": "~1.0.0",   "orchestrate": "0.0.2",   "chance": "~0.5.3" },  "devDependencies": {   "mocha": "~1.15.1" } 
like image 254
Adron Avatar asked Dec 12 '13 19:12

Adron


1 Answers

You can get AWS Elastic Beanstalk to run npm install in production mode if you set the environment variable NPM_CONFIG_PRODUCTION=true. You can do this through the Elastic Beanstalk web console.

Alternatively, save the following text to any file with suffix .config inside a directory called .ebextensions in the project root and you can achieve the same thing without having to set them every time in the web console:

option_settings:    - option_name: NPM_CONFIG_PRODUCTION     value: true 

Note: make sure you're using spaces, not tabs, as it's YAML format.

I found that the time to update new node.js code in a t1.micro environment went down from about 5 minutes to 90 seconds, now that it wasn't installing all the devDependencies such as grunt, karma, mocha, etc.

like image 109
rgareth Avatar answered Oct 05 '22 14:10

rgareth