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

后端 未结 4 1817
醉酒成梦
醉酒成梦 2021-02-18 19:19

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 wo

4条回答
  •  温柔的废话
    2021-02-18 19:45

    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.

提交回复
热议问题