diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts index d161283685a21..60ea23305f527 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts @@ -64,6 +64,7 @@ export class LocalBundler implements cdk.ILocalBundling { process.stderr, // redirect stdout to stderr 'inherit', // inherit stderr ], + cwd: path.dirname(path.join(this.props.projectRoot, this.props.relativeEntryPath)), }); return true; } @@ -107,7 +108,7 @@ export class DockerBundler { image, command: ['bash', '-c', command], environment: props.environment, - workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)), + workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)).replace(/\\/g, '/'), // Always use POSIX paths in the container, }; } } diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts index 7461a88627f2f..cd6a67709ddba 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts @@ -241,6 +241,7 @@ test('Local bundling', () => { ], expect.objectContaining({ env: expect.objectContaining({ KEY: 'value' }), + cwd: '/project/folder', }), );