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

Can't create project with yarn [modern] dlx #4923

Closed
1 task done
nickserv opened this issue Sep 30, 2022 · 8 comments
Closed
1 task done

Can't create project with yarn [modern] dlx #4923

nickserv opened this issue Sep 30, 2022 · 8 comments
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@nickserv
Copy link
Contributor

nickserv commented Sep 30, 2022

What version of astro are you using?

1.4.0

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

None

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

Using yarn dlx (the yarn modern version of yarn/create) leads to a package installation error:

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1s 365ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 1s 539ms

/private/var/folders/2t/t4byzhn576n41yk4yqzx3tsw0000gn/T/xfs-6b77a3cd/dlx-26562/.pnp.cjs:9004
  return Object.defineProperties(new Error(message), {
                                 ^

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

Required package: #ansi-styles (via "#ansi-styles/package.json")
Required by: chalk@npm:5.0.1 (via /Users/nick/.yarn/berry/cache/chalk-npm-5.0.1-6afcb94227-8.zip/node_modules/chalk/source/index.js)

    at makeError (/private/var/folders/2t/t4byzhn576n41yk4yqzx3tsw0000gn/T/xfs-6b77a3cd/dlx-26562/.pnp.cjs:9004:34)
    at resolveToUnqualified (/private/var/folders/2t/t4byzhn576n41yk4yqzx3tsw0000gn/T/xfs-6b77a3cd/dlx-26562/.pnp.cjs:9923:21)
    at Object.resolveToUnqualified (/private/var/folders/2t/t4byzhn576n41yk4yqzx3tsw0000gn/T/xfs-6b77a3cd/dlx-26562/.pnp.cjs:10067:26)
    at resolve$1 (file:///private/var/folders/2t/t4byzhn576n41yk4yqzx3tsw0000gn/T/xfs-6b77a3cd/dlx-26562/.pnp.loader.mjs:224:31)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.10.0

Link to Minimal Reproducible Example

yarn dlx create-astro

Participation

  • I am willing to submit a pull request for this issue.

Workaround

Create the project with yarn create and then upgrade to yarn modern with yarn set version stable.

@matthewp matthewp added the - P2: has workaround Bug, but has workaround (priority) label Sep 30, 2022
@mandar1jn
Copy link
Contributor

This is actually an issue with yarn/chalk/both and not an issue with Astro itself chalk/chalk#531 yarnpkg/berry#3879

@nickserv
Copy link
Contributor Author

nickserv commented Oct 2, 2022

@matthewp added the p2-has-workaround label

I'm aware that yarn resolutions can be used as a workaround, but as far as I'm aware there isn't a way to use this with yarn dlx globally. If you have a workaround can you please explain?

@mandar1jn This is actually an issue with yarn/chalk/both and not an issue with Astro itself chalk/chalk#531 yarnpkg/berry#3879

It seems like chalk isn't ideal for projects using ESM in package.json. Could we picocolors instead? It's used by Vite, it's smaller, it's faster, and it supports PNP. We'd also need to replace ora with a progress library that doesn't depend on chalk.

@mandar1jn
Copy link
Contributor

Replacing chalk with an alternative that supports pnp would indeed work. Also, you’d indeed need to replace ora if it uses chalk

@nickserv
Copy link
Contributor Author

nickserv commented Oct 2, 2022

Do you have any recommendations for progress libraries?

@mandar1jn
Copy link
Contributor

no I don't sadly

@mrienstra
Copy link
Contributor

mrienstra commented Oct 28, 2022

You can try yarn v4, yarn set version canary, more details here:
chalk/chalk#553 (comment)
... though huh, yarn set version canary isn't global, so... Oh yeah, corepack:
corepack prepare yarn@canary --activate
as per https://nodejs.org/docs/latest-v18.x/api/corepack.html#upgrading-the-global-versions
(gotta open a PR edit: 🤦 work on my existing PR to add that to the yarn install docs)

Edit: Yarn v3.2.4 also contains the fix from yarnpkg/berry#4862 (source: yarnpkg/berry#4850 (comment)), Yarn v.3.2.4 is used for yarn dlx beginning with Corepack v0.15.0.

Alas Node v18.12.0 & v19.0.0 both use Corepack 0.14.2 -- which makes sense, Corepack 0.15.0 isn't even 24 hours old -- so you'll have to wait for the next Node release. Or update Corepack, but that seems to be slightly discouraged.

@matthewp
Copy link
Contributor

Closing per #4923 (comment), not an issue with Astro.

@mrienstra
Copy link
Contributor

Work around, as per Corepack docs:

corepack yarn@3.2.4 dlx create-astro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

4 participants