aws / aws/aws-cdk

(@aws-cdk/aws-lambda-nodejs): fails on Windows when using `pnpm`

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

Description

### Describe the bug

I've installed `pnpm` on Windows using the following method from the docs https://pnpm.io/installation#on-windows

```ps1
iwr https://get.pnpm.io/install.ps1 -useb | iex
```

this makes the command `pnpm` work in both Command Prompt and PowerShell. However the following line of code appends `.cmd` to the `pnpm` command https://github.com/aws/aws-cdk/blob/10b322167131d299559cbe2f6bab3ebebcb58a11/packages/aws-cdk-lib/aws-lambda-nodejs/lib/package-manager.ts#L73

### Expected Behavior

for bundling to pass without errors

### Current Behavior

Instead of `pnpm.cmd`, it should just invoke `pnpm`. Otherwise, when running `cdk deploy` with a node js lambda using `pnpm` as a package manager, you get the follow error during bundling

```
'pnpm.cmd' is not recognized as an internal or external command,
operable program or batch file.
```

### Reproduction Steps

I've tried reproducing this in an isolated project but it didn't trigger the error, so I'm struggling to find out what scenario triggers `pnpm.cmd` to be fed to the shell

### Possible Solution

Instead of `pnpm.cmd`, `runBinCommand` should just invoke `pnpm` when on Windows

### Additional Information/Context

_No response_

### CDK CLI Version

2.102.0

### Framework Version

2.102.0

### Node.js Version

v18.18.0

### OS

Windows 11

### Language

TypeScript

### Language Version

5.2.2

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with packages/aws-cdk-lib/aws-lambda-nodejs/lib/package-manager.ts at the linked line where the pnpm command is assembled. Reproduce bundling for a Node.js Lambda using pnpm on Windows, then verify that cdk deploy completes without the reported command-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript
Domain
backend, build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.