'how to change npm install command in ElasticBeanstalk (Node)?

I knew that the elastic beanstalk environments will execute the command npm --production install.

But, from https://github.com/npm/cli/issues/4027, npm v8 (Node 16) executes scripts even when doing npm --production install.

According to the npm documentation, it is supposed not to do prepare scripts when we give some arguments like --production. However, the npm v8 bug still exists so that prepare script will be executed when I deploy my Node.js application to ElasticBeanstalk.

So, I want to change ElasticBeanstalk's command npm --production install to npm install --production --ignore-scripts. Is there any way to accomplish this?



Solution 1:[1]

I believe you can create a .npmrc file then add:

ignore-scripts=true

https://docs.npmjs.com/cli/v7/configuring-npm/npmrc#files

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 amerikan