Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cdk-cli): (Does't use pnpm to install dependencies when invoked with pnpx) #23205

Open
ShivamJoker opened this issue Dec 2, 2022 · 8 comments · May be fixed by #30661
Open

(cdk-cli): (Does't use pnpm to install dependencies when invoked with pnpx) #23205

ShivamJoker opened this issue Dec 2, 2022 · 8 comments · May be fixed by #30661
Assignees
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI

Comments

@ShivamJoker
Copy link

Describe the bug

When I try to init CDK with pnpm it starts installing dependencies using npm

screenshot showing npm install getting executed

Expected Behavior

CDK should use pnpm to install dependencies instead of just going for npm

Current Behavior

Installs package using npm

Reproduction Steps

Create a new project with

pnpx cdk init app --language typescript

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.53.0

Framework Version

No response

Node.js Version

16

OS

Arch Linux

Language

Typescript

Language Version

No response

Other information

No response

@ShivamJoker ShivamJoker added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 2, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Dec 2, 2022
@ShivamJoker ShivamJoker changed the title (cdk init): (Does't use pnpm to install dependencies when invoked with pnpx) (cdk-cli): (Does't use pnpm to install dependencies when invoked with pnpx) Dec 2, 2022
@peterwoodworth
Copy link
Contributor

Under the hood we're executing an npm install while cdk init command is being ran. We could potentially allow for pnpm as well

const command = 'npm';

@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p2 feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 5, 2022
@ShivamJoker
Copy link
Author

I see, I am up for contribution.
How do we know which package manager was used to initiate the install?

Does it get passed in command line arguments? process.args

@peterwoodworth
Copy link
Contributor

Glad to hear you're interested in contributing! Be sure to check out our contributing guide

I'm not sure there's a way to detect if cdk init was called with pnpx. We may have to introduce a cli option for this

@ShivamJoker
Copy link
Author

@peterwoodworth I found a library which parses the package manager from environment variable - https://github.com/zkochan/packages/tree/main/which-pm-runs

I will integrate this with fallback to npm.

Let me know if this works for you.

@mrgrain
Copy link
Contributor

mrgrain commented Dec 9, 2022

@ShivamJoker The templates are currently fixed for npm. Not that we would never want to support anything else, but they are deliberately basic.

If you are looking at improving your personal/company workflow. May I suggest you have a look at projen which fully support pnpm

@ShivamJoker
Copy link
Author

The templates are currently fixed for npm

@mrgrain I don't see the downside of improving the developer experience.
Why to force people to use npm if there are better tools available.

I looked at projen but it seems like a 3rd party tool which should not be recommended for several reasons like if its updated properly, if it has bugs or security flaws and if we encounter any issues then AWS won't take any responsibility.

@tripplilley
Copy link

The templates are currently fixed for npm

@mrgrain The Yarn Rulebook advises using $npm_execpath instead of npm run in package.json scripts. That might help?

It's at least portable amongst npm, pnpm, and yarn (all I've tested so far).

@mrgrain
Copy link
Contributor

mrgrain commented Mar 20, 2023

Absolutely. I reckon there are 3 places that would need to be adjusted:

  • the tool that is used to install dependencies
  • the scripts in package.json (not a thing actually)
  • the app in cdk.json

@IanKonlog IanKonlog self-assigned this Jun 11, 2024
@IanKonlog IanKonlog linked a pull request Jun 25, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
6 participants