(@aws-cdk/aws-lambda-nodejs): ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Cannot read properties of undefined #26381
Labels
@aws-cdk/aws-lambda-nodejs
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
Can not use
new NodejsFunction()
withesbuild
in a PNPM monorepo setup.Expected Behavior
Commands like
cdk synth
succeed.Current Behavior
Commands like
cdk synth
fail.Reproduction Steps
git clone [email protected]:awesome-cdk/aws-cdk-nodejsfunction-issue.git
cd aws-cdk-nodejsfunction-issue
pnpm install
cd packages/cdk
pnpm exec cdk synth
More detailed description of the issue:
packages/frontend
for your frontend andpackages/cdk
for your IaC and backend.new NodejsFunction()
construct anywhere in the CDK appesbuild
for local bundling, instead of Docker, because it's faster and more efficientpnpm install
cdk synth
Also see the recent GitHub Actions failure in the minimum reproducable repo for a simple example that fails.
Possible Solution
When trying to use
esbuild
to compile the Lambda TS into JS, it seems that the construct executes a command like thisbash -c pnpm exec -- esbuild --bundle ...
at the monorepo root. Instead, the command should be executed from the context of the CDK package root (in this case, ./packages/cdk).I have verified this by running these very trivial commands:
At the monorepo root - doesn't work:
pnpm exec esbuild --help
At packages/cdk - works:
pnpm exec esbuild --help
Additional Information/Context
No response
CDK CLI Version
2.85.0 (build 4e0d726)
Framework Version
No response
Node.js Version
18.16.0
OS
MacOS
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: