-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use --omit=dev
instead
#553
Comments
Ok, it looks like the failure isn't really about the "--production" switch. I now have logs with --debug enabled and I'm seeing this:
So actually it's esbuild crashing with a SIGSEGV in its own postinstall action. The "--production" error is there only because the npm builder shows stderr upon non-zero exit code from npm, but essentially it's unrelated. I now removed esbuild from package.json and left only its globally installed version. And I also call "esbuild --version" just before "sam build" in the CI/CD script to make sure that esbuild is fully installed. Guess what, I'm yet to see any failures. |
Is the issue that |
I would say that the issue is NodejsNpmEsbuildBuilder "lying" about the error. It shows...
...which is misleading, because the actual reason is esbuild crashing with a segmentation violation without any traces in stderr. In other words, NodejsNpmEsbuildBuilder should not blindly show the latest stderr output as the reason for build failure. I had to use --debug to find out the true reason after spending hours speculating why "npm WARN config production" could break the build (it didn't). As for esbuild dying with a SIGSEGV, my workaround was to install and test it (esbuild --version) before running sam build in my CI/CD script. But that's a whole different story. |
Description:
It looks like at some point npm deprecated the
--production
parameter and started WARNing about it in stderr, which seems to breaksam 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.7Alternatively, just run npm i --production and observe the same warning. Clearly, it's not supposed to be called with --production anymore.
Observed result:
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)
image: node:18
sam --version
: 1.98.0So 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.
The text was updated successfully, but these errors were encountered: