Description:
When running sam build the NodejsNpmEsbuildBuilder:NpmInstall stage fails with an error of Error: NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm error code EUNKNOWNCONFIG.
The issue is that the npm install flags include a long deprecated --unsafe-perm parameter (Deprecated since npm v7). This was simply ignored for a long time but as of npm v12 npm now explicitly errors on unknown parameters.
Steps to reproduce:
On an existing esbuild-based SAM project:
npm i -g npm@12
sam build
Observed result:
2026-07-15 09:50:14,894 | NODEJS installing production dependencies in: /var/folders/kc/hyc5njk52pl4s9j1ksq4vxxc0000gq/T/tmp_d2jxm70
2026-07-15 09:50:14,895 | executing NPM: ['npm', 'install', '-q', '--no-audit', '--no-save', '--unsafe-perm', '--production']
2026-07-15 09:50:16,568 | NodejsNpmEsbuildBuilder:NpmInstall failed
Traceback (most recent call last):
File "aws_lambda_builders/workflows/nodejs_npm/actions.py", line 115, in execute
File "aws_lambda_builders/workflows/nodejs_npm/npm.py", line 72, in run
aws_lambda_builders.workflows.nodejs_npm.exceptions.NpmExecutionError: NPM Failed: npm warn config production Use `--omit=dev` instead.
npm error code EUNKNOWNCONFIG
npm error Unknown cli flag:
npm error - --unsafe-perm
npm error Run `npm help config` for supported options.
npm error A complete log of this run can be found in: <redacted>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "aws_lambda_builders/workflow.py", line 374, in run
File "aws_lambda_builders/workflows/nodejs_npm/actions.py", line 118, in execute
aws_lambda_builders.actions.ActionFailedError: NPM Failed: npm warn config production Use `--omit=dev` instead.
npm error code EUNKNOWNCONFIG
npm error Unknown cli flag:
npm error - --unsafe-perm
npm error Run `npm help config` for supported options.
npm error A complete log of this run can be found in: <redacted>
Build Failed
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOS and Linux
- If using SAM CLI,
sam --version: 1.163.0
- AWS region: N/A
Add --debug flag to any SAM CLI commands you are running
Description:
When running
sam buildtheNodejsNpmEsbuildBuilder:NpmInstallstage fails with an error ofError: NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm error code EUNKNOWNCONFIG.The issue is that the
npm installflags include a long deprecated--unsafe-permparameter (Deprecated since npm v7). This was simply ignored for a long time but as of npm v12 npm now explicitly errors on unknown parameters.Steps to reproduce:
On an existing esbuild-based SAM project:
npm i -g npm@12sam buildObserved result:
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version: 1.163.0Add --debug flag to any SAM CLI commands you are running