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

astro tried to access shikiji-core, but it isn't declared in its dependencies #9921

Closed
1 task done
buffalo-thb opened this issue Feb 1, 2024 · 2 comments · Fixed by #10063
Closed
1 task done

astro tried to access shikiji-core, but it isn't declared in its dependencies #9921

buffalo-thb opened this issue Feb 1, 2024 · 2 comments · Fixed by #10063
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord

Comments

@buffalo-thb
Copy link

Astro Info

Astro                    v4.2.8
Node                     v20.11.0
System                   macOS (x64)
Package Manager          yarn
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When I use create astro CLI to create a new project,by step 2, yarn/npm/pnpm run dev, I got the Error like this:

Error: astro tried to access shikiji-core, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: shikiji-core (via "shikiji-core/package.json")
Required by: astro@npm:4.2.8 (via /Users/xxx/.yarn/berry/cache/astro-npm-4.2.8-b761f9a737-10c0.zip/node_modules/astro/dist/core/config/schema.js)

at makeError (/Users/xxx/Documents/learn/astro/hello-astro/.pnp.cjs:11499:34)
at resolveToUnqualified (/Users/xxx/Documents/learn/astro/hello-astro/.pnp.cjs:13147:21)
at Object.resolveToUnqualified (/Users/xxx/Documents/learn/astro/hello-astro/.pnp.cjs:13327:26)
at resolve$1 (file:///Users/xxx/Documents/learn/astro/hello-astro/.pnp.loader.mjs:1993:31)

When I install "shikiji-core" myself, the error was resolved.

What's the expected result?

Start server normally

add "shikiji-core" into the package.json

Link to Minimal Reproducible Example

https://github.com/buffalo-thb/hello2

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 1, 2024
@bluwy
Copy link
Member

bluwy commented Feb 1, 2024

Yeah it should be in dependencies instead of devDependencies. Feel free to send a PR for that!

@bluwy bluwy added - P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord and removed needs triage Issue needs to be triaged labels Feb 1, 2024
@djsiddz
Copy link

djsiddz commented Feb 2, 2024

If someone needs a temporary workaround using yarn, I'm leaving this code here. Add a .yarnrc.yml file to the root of your project. Include the below code:

packageExtensions: {
  astro@4.3.1: {
    dependencies: {
      shikiji-core: "^0.9.18"
    }
  }
}

After adding the file, run yarn install. Then yarn build or yarn dev should work fine.

I faced this issue with Astro v4.3.1. You can update astro's version to be specific to what you are using.
Also shikiji-core's version has been picked from the pull request above.

Once this is fixed in Astro's next release, the .yarnrc.yml file or at least the above lines can be safely removed from this file.

P.S.: Possibly, your first thought would be to use yarn patch. However, the dependencies are computed at fetch time and not at resolution time. Hence packageExtensions is the way to go.

References:
Yarn Package Patching - See Limitations
Yarn Settings (.yarnrc.yml) - See packageExtensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) good first issue Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord
Projects
None yet
3 participants