aws / aws/aws-cdk

(aws-lambda-nodejs): Windows bundling issue with chain command

Open Beginner friendly
#30,543 3 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda-nodejs bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

We are not able to bundle the lambdas using `aws-cdk`. we get `Illegal character '"' in input file.` error.
Windows CMD doesn't not support "&&" as chain command, and instead we should use ";"
```ts
// packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts

function chain(commands: string[]): string {
return commands.filter(c => !!c).join(' && ');
}
```
we need to change this function to
```ts
// packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
function chain(commands: string[]): string {
const sign = this.osPlatform === 'win32' ? ';' : '&&';
return commands.filter(c => !!c).join(` ${sign} `);
}
```

### Expected Behavior

`yarn cdk deploy ..` should be able to bundle the lambdas on `windows`

### Current Behavior

`yarn cdk deploy ..` raises `Illegal character '"' in input file.` error on windows.

### Reproduction Steps

Try to run following sample on windows
```
const stack = cdk.Stack()
new lambdaNodeJs.NodejsFunction(stack, 'id', ...)
```
and then try to bundle the stack
```
yarn cdk synth
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.133.0

### Framework Version

_No response_

### Node.js Version

v22.1.0

### OS

windows

### Language

TypeScript

### Language Version

5.4.3

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Open packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts and inspect the chain function and how the bundling platform is selected. Run the reported yarn cdk synth reproduction on Windows, then verify that bundling succeeds there while non-Windows command chaining remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.