Skip to content

NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use --omit=dev instead #553

@yegorpetrov

Description

@yegorpetrov

Description:

It looks like at some point npm deprecated the --production parameter and started WARNing about it in stderr, which seems to break sam build.

I'm not sure which version of npm introduced that but the relevant range in npm code git-blames back to a couple years ago.

I found --production still in unconditional use in the corresponding builder {actions.py:111}. I think it needs to be upgraded to --omit=dev depending on the npm version.

Steps to reproduce:

sam build with a node_modules layer and npm version >= 9.6.7
Alternatively, just run npm i --production and observe the same warning. Clearly, it's not supposed to be called with --production anymore.

Observed result:

 Running NodejsNpmEsbuildBuilder:CopySource
 Running NodejsNpmEsbuildBuilder:CopySource
 Running NodejsNpmEsbuildBuilder:NpmInstall
 Running NodejsNpmEsbuildBuilder:NpmInstall
 Running NodejsNpmEsbuildBuilder:NpmInstall
 Running NodejsNpmEsbuildBuilder:EsbuildBundle
 Running NodejsNpmEsbuildBuilder:EsbuildBundle
 Running NodejsNpmEsbuildBuilder:EsbuildBundle
Build Failed
Error: NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use `--omit=dev` instead.

Expected result:

Wouldn't expect to see the warning, and wouldn't expect it to be treated as an error.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: image: node:18
  2. If using SAM CLI, sam --version: 1.98.0
  3. AWS region: us-east-1

Add --debug flag to any SAM CLI commands you are running

So the CI/CD pipeline failed, and I went to create this bug report, and then I read about --debug and added it to sam commands in the pipeline... But it did not fail this time! I'm confused and I cannot reproduce this issue reliably. Still, just looking at the code of aws-lambda-builders and npm, the problem seems to be present.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions