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

🐛 BUG: Not getting Astro to work using Yarn v3 (Berry) #3450

Closed
1 task
MartijnHarmenzon opened this issue May 26, 2022 · 8 comments
Closed
1 task

🐛 BUG: Not getting Astro to work using Yarn v3 (Berry) #3450

MartijnHarmenzon opened this issue May 26, 2022 · 8 comments

Comments

@MartijnHarmenzon
Copy link

MartijnHarmenzon commented May 26, 2022

What version of astro are you using?

astro@1.0.0-beta.34

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

Yarn v3 Berry

What operating system are you using?

Windows

Describe the Bug

Hello. I am reporting you this issue after talking to @aFuzzyBear on Discord. link-to-thread

I would love to get Astro working with Yarn v3 (Berry). But when using the following steps:

  • yarn set version berry
  • yarn create astro

This wil resolve in the following error:

Error: chalk tried to access #ansi-styles, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Any ideas?

Link to Minimal Reproducible Example

https://martijnharm-astrotailwi-dq52nanes0o.ws-eu46.gitpod.io/

Participation

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

@MartijnHarmenzon
Copy link
Author

You need to use shamfully-hoist with yarn: https://github.com/withastro/docs/blob/edea9edff2119a0ac11365e99432b4cd205effaa/.npmr

Thanks, but tried before I created the issue. It doesn't make a difference. But maybe I am placing the file in the wrong location. What should I do with the file exactly?

@matthewp
Copy link
Contributor

@MartijnHarmenzon put it in the root of your project before calling yarn install. You probably want to remove your node_modules folder.

@MartijnHarmenzon
Copy link
Author

MartijnHarmenzon commented May 28, 2022

@matthewp Unfortunately it did not work. I did the following steps:

  • create folder
  • add .npmrc file
  • yarn init -2
  • yarn install
  • yarn create astro

The above results in the same errors.

@MartijnHarmenzon
Copy link
Author

MartijnHarmenzon commented May 28, 2022

Update.. @aFuzzyBear @matthewp

When adding the follwing to the .yarnrc.yml file as per this article

nodeLinker: pnpm
pnpMode: loose

Astro is able to run the astro create.

But when trying to run yarn dev, in the my-astro-site folder, it will give the following error.

The project in E:\dev\playground\astro-tailwind-alpine-v2\frontend12\package.json doesn't seem to have been installed - running an install there might help

Running the yarn install, as suggested, doesn't help. Any ideas?

@matthewp
Copy link
Contributor

I'm not sure I can help any more, unfortunately. If you figure it out let us know and we'll update the documentation.

fwiw I would recommend not using Yarn any more. pnpm provides similar features but is more compatible with the ecosystem.

@retronav
Copy link
Contributor

Hi @MartijnHarmenzon , right now the most suitable solution for getting Astro to work for Berry is to use node_modules for linking:

nodeLinker: node-modules

Since we need shamefully-hoist in .npmrc, that indicated something might be using other node modules directly from node_modules/ directory, hence why Yarn PnP is not working (just a wild guess).

@matthewp
Copy link
Contributor

matthewp commented Jun 1, 2022

We've turned this into a docs issue, thanks for the suggestion @retronav! Going to track this further there: withastro/docs#700

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

No branches or pull requests

4 participants