GoogleCloudPlatform/buildpacks

Be able to add cli options to npm install

jlopezxs opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
I'm trying to improve some build time and trying to add --cache .npm --prefer-offline --no-audit to the npm install script.
Checking the code I didn't see how to do that: https://github.com/GoogleCloudPlatform/buildpacks/blob/main/cmd/nodejs/npm/main.go#L120

Describe the solution you'd like
Maybe like gcp-build could exists a gcp-install or a ENV variable to add some configuration in the installation step

Describe alternatives you've considered
I'm open to any workaround to test it. If there are another env or some configuration that not affects to all the application infrastructure like move from App Engine to Cloud Run or Flex with custom docker image.

I had a similar issue and solved it by creating a .npmrc file that listed all the additional arguments I wanted. You can also instead use env variables in your project.toml with the syntax NPM_CONFIG_*. The docs and supported arguments are here: https://docs.npmjs.com/cli/v10/using-npm/config