projen icon indicating copy to clipboard operation
projen copied to clipboard

`projen new node` with defaults requires yarn to be installed

Open mrgrain opened this issue 3 years ago • 4 comments

Creating any new basic node project forces yarn to be available unless the --package-manager flag is set.

When --package-manager is not provided, the default should be more clever and check if yarn is even installed (and which version of it). If it's yarn2 or not available we should assume --package-manager=npm (or =yarn2 respectively) was passed in.

Alternatively, maybe the default should just be npm which is kind of guaranteed to be available. Or we could use corepack to install yarn/pnpm

$ npx projen new awscdk-construct
👾 Project definition file was created at /home/user/projen-construct-library/.projenrc.js
node:child_process:960
    throw err;
    ^

Error: Command failed: yarn install --check-files
/bin/sh: 1: yarn: not found

mrgrain avatar Feb 15 '23 10:02 mrgrain

I just took way too long to do an npx projen new awscdk-construct.

Background, this is the first time I am using projen and a lot of the tutorials are old. The above should be all that works. But it seems to only work with yarn version <= 2. I saw the PR that added support for the newer yarn https://github.com/projen/projen/pull/2426 but did not know how to select it. Also I didn't have Yarn install so volta install yarn installs yarn 3, which also doesn't seem to be supported?

Anyway, from above I learned that I can use: npx projen new awscdk-construct --package-manager=npm

rehanvdm avatar May 09 '23 06:05 rehanvdm

Thank you, appreciate the feedback.

You should be able to do npx projen new awscdk-construct --package-manager=yarn2 as well. The naming might not be ideal though, it's more a yarn 2+

mrgrain avatar May 09 '23 09:05 mrgrain

Sure thing, do you think it is worth the while to mention something on the README? I can't be the only that has started the project and faced this problem

rehanvdm avatar May 09 '23 11:05 rehanvdm

Sure thing, do you think it is worth the while to mention something on the README? I can't be the only that has started the project and faced this problem

Yes please! I'd be very happy about a PR!

mrgrain avatar May 09 '23 12:05 mrgrain