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

.yarnrc.yml for Yarn, via create-astro? #4851

Closed
1 task done
mrienstra opened this issue Sep 23, 2022 · 5 comments · Fixed by #4842
Closed
1 task done

.yarnrc.yml for Yarn, via create-astro? #4851

mrienstra opened this issue Sep 23, 2022 · 5 comments · Fixed by #4842

Comments

@mrienstra
Copy link
Contributor

mrienstra commented Sep 23, 2022

What version of astro are you using?

latest

What package manager are you using?

Yarn (for testing purpose, otherwise pnpm)

What operating system are you using?

MacOS

Describe the Bug

All of the templates (/examples/) include .npmrc files (e.g.) that contain:

# Expose Astro dependencies for `pnpm` users
shamefully-hoist=true

This doesn't seem to be necessary anymore?

npm create astro@latest -- --directory temp --template docs --install 0 --git 0 --typescript base
cd temp
rm .npmrc
pnpm install
pnpm run dev

... But probably I'm missing something. Anyway, the rest of this was written under the assumption that pnpm still needs .npmrc, so let's go with that...

For Yarn, we have a Using Astro with Yarn 2+ (Berry) section in the Troubleshooting guide (added in withastro/docs#749), which suggests creating a yarnrc.yml (missing initial dot, should be .yarnrc.yml, PR to fix) that contains:

nodeLinker: "node-modules"

So right now, there's a file to support pnpm that is cruft for npm & yarn (which doesn't bother me, I'm on a pnpm kick at the moment!). Maybe we should do the same for Yarn? Or neither, see option (B) below.

A) Do the same for Yarn 2+ users: Add .yarnrc.yml to all of the templates. Yarn users likely outnumber pnpm users.

B) Remove the .npmrc files from the templates, and extend create-astro to create .yarnrc.yml if invoked by Yarn (already detected and used to install dependencies), or .npmrc if invoked by pnpm.


Alternate solution for Yarn (source), put the following in .yarnrc.yml:

packageExtensions:
  chalk@5.0.1:
    dependencies:
      "#ansi-styles": npm:ansi-styles@6.1.0
      "#supports-color": npm:supports-color@9.2.2

I tested this locally. yarn create astro is failing for me locally (I'll open an issue), so I used npm create astro@latest -- --directory temp2 --template docs --install 0 --git 0 --typescript base to make the project, then made a .yarnrc.yml with the content above, then I was able to run yarn & yarn dev without issue.

Edit: weird, this seems to be viable when using node v18, but not with node v16 (both with yarn 3.2.3), I'll double-check that later.


All of the above tested with node v18.9.0, npm 8.19.1, corepack 0.14.0, yarn 3.2.3, pnpm 7.11.0, MacOS 12.3, ARM64.

Edit: Also tested with node v16.17.0, npm 8.15.0, corepack 0.12.1, yarn 3.2.3, pnpm 7.11.0, MacOS 12.3, ARM64.

Link to Minimal Reproducible Example

n/a

Participation

  • I am willing to submit a pull request for this issue.
@mrienstra
Copy link
Contributor Author

mrienstra commented Sep 23, 2022

Oh, just realized I'm using node v18, I'll check with node v16.17, just in case...

Edit: everything I wrote above is true for node v16 as well, with the exception of:

yarn create astro is failing for me locally

Edit 2: Whoops, that was with yarn 1.22.19, yarn create astro is still failing with node v16, specifically:
node v16.17.0, npm 8.15.0, corepack 0.12.1, yarn 3.2.3, pnpm 7.11.0, MacOS 12.3, ARM64.

@bluwy
Copy link
Member

bluwy commented Sep 23, 2022

FWIW I've removing the need for the .npmrc for pnpm at #4842.

Yarn users likely outnumber pnpm users

That's yarn 1 vs pnpm. For yarn 2 and 3 however 😅

@mrienstra
Copy link
Contributor Author

FWIW I've removing the need for the .npmrc for pnpm at #4842.

🙌
🥳 HECK YEAH!

Ha, I was just about to open a PR to add path-browserify as a dep for @astro/rss (as I was exploring dropping shamefully-hoist=true with Yarn), no point opening it now. :)

Yarn users likely outnumber pnpm users

That's yarn 1 vs pnpm. For yarn 2 and 3 however 😅

Interesting!

@matthewp
Copy link
Contributor

Can this be closed when #4842 is merged then?

@mrienstra
Copy link
Contributor Author

Can this be closed when #4842 is merged then?

Yes, this can be closed by #4842. I'll do another round of testing after that to see if there are remaining related issues, but fingers crossed, hoping to find not a one!

@bluwy bluwy linked a pull request Sep 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants