Open sebastiaan-dev opened 9 months ago
Is the codesandbox private?
I am not sure how to share it properly, can you either try one of the following links:
If either of the above do not work I will make a GitHub repo.
I didn't check the repo but since you're talking about shikiji-core, related PR #10063
A release with the fix for this issue should arrive soon. Closing.
What is soon in this case, 1 month? It is still broken at the moment @ematipico.
What is soon in this case, 1 month? It is still broken at the moment @ematipico.
No need to be sarcastic, I'll reopen the issue
It was not my intention to be sarcastic, it was a genuine question, but thank you for reopening the issue 👍.
I checked again and it seems to be an issue with the starlight template, as the minimal template succeeds. I can create the starlight template by selecting no at the Do you plan to write TypeScript?
question, otherwise it results in the Unexpected end of JSON input
error. Both do still have the aforementioned behaviour of wanting to install @astrojs/check typescript
with npm
. This is when I choose to install the dependencies later. If I instead install the dependencies with Houston it ignores the monorepo and sets up its own instance inside the yarn workspace (.yarn
, yarn.lock
, .pnp.cjs
, etc.) causing conflicts with the parent yarn instance. This is with yarn 4.1.0
and astro 4.4.0
.
Could you clarify what the issue is?
astro add
attempts to use npm
instead of yarn
in certain cases, requiring you to skip that step and install dependencies manually. Is there something more?
I cannot setup/build the generated astro project, to clear it up I have noted the steps I tried below:
First create a new mono-repo:
mkdir astro-starlight-bug
cd astro-starlight-bug
yarn init -2
Then change the package.json
to reflect the following:
{
"name": "astro-starlight-bug",
"packageManager": "yarn@4.1.0",
"workspaces": [
"apps/*"
]
}
Then create the corresponding directory for the workspaces:
mkdir apps
cd apps
Then do one of the following options below:
Say yes to everything except creating a new git repository:
yarn create astro --template starlight
This results in:
██████ Project initializing...
✔ Template copied
▶ TypeScript customizing...
□ Dependencies
▲ error Error: Unexpected end of JSON input
Say yes to everything, except creating a new git repository and to using typescript.
yarn create astro --template starlight
This results in yarn.lock
, .yarn
etc. being added in /apps/<random-starlight-name>
. Ignoring the fact that there is already a top level yarn configuration. This in turn leads to crashes for both yarn dev
and yarn build
.
Say no to everything except the random name:
yarn create astro --template starlight
Then do the following:
cd <random-starlight-name>
# install dependencies
yarn
# yay this works
yarn dev
But executing yarn build
results in:
node:events:492
throw er; // Unhandled 'error' event
^
Error: spawn /bin/sh ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /bin/sh',
path: '/bin/sh',
spawnargs: [
'-c',
'npx -y pagefind --site ../../../../../../../../../../../apps/civil-cycle/dist'
]
}
Node.js v20.9.0
It is of note that my earlier remarks regarding shikiji-core
no longer hold, the above options were tried using astro v4.4.2
.
For anyone still having the issue with @astrojs/check
and typescript
not found in a yarn workspace, make sure to use the nohoist for astro packages.
For my usecase:
{
"private": true,
"workspaces": {
"packages": [
"notAstroApp",
"astroApp"
],
"nohoist": ["**/@astrojs/**"]
}
}
With the file structure:
| package.json
| node_modules/
| notAstroApp
| node_modules/
| astroApp
| node_modules/
astro check will only check for the packages in the current working directory, however yarn may decide to put astro in the shared dependencies of your app, if this happends, astro CLI will be unable to locate your astro check install. https://github.com/withastro/astro/blob/bab700d69085b1de8f03fc1b0b31651f709cbfe3/packages/astro/src/cli/install-package.ts#L21
nohoist ensures astro is installed in your astroApp
node_modules and not in the shared node_modules folder
I hope this helps !
I use npm workspace, but I have bug with monorepo too:
To continue, Astro requires the following dependency to be installed: @astrojs/check.
Astro will run the following command:
If you skip this step, you can always run it yourself later
╭────────────────────────────────────────╮
│ npm install @astrojs/check typescript │
╰────────────────────────────────────────╯
✔ Continue? … no
08:06:50 [ERROR] [check] The `@astrojs/check` and `typescript` packages are required for this command to work. Please manually install them into your project and try again.
My package.json
:
{
"private": true,
"workspaces": [
"packages/*"
],
"dependencies": {
...
},
"devDependencies": {
...
}
}
Project structure:
/
├── node_modules/
├── packages
│ ├── astrojs-project
│ └── not-astrojs
├── package.json
└── other files
Please open a dedicated issue
Please open a dedicated issue
I copied my problem to separate issue: https://github.com/withastro/astro/issues/11608
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Preconditions
Following commands were executed during the creation of the monorepo:
Describe the Bug
When trying to build an Astro project inside a monorepo using yarn workspaces Astro crashes. I tried 2 different approaches. It is of note that I added the following in
.yarnrc.yml
due to an error withshikiji-core
:Approach 1
Install starlight with the below command in a directory
<monorepo-root>/apps/
, whereapps
is declared as a workspace with yarn.Then the configuration crashes with the following error:
Approach 2
Install starlight with the below command in a directory which lives outside of the monorepo.
I confirm everything works,
yarn dev
andyarn build
succeed. Then I place the newly created directory by astro inside theapps
directory. I remove theyarn.lock
andnode-modules
, and rename the package name to reflect my repository. I reinstall the dependencies, thenyarn dev
succeeds butyarn build
fails by first trying to install dependencies withnpm
:Installing yes or no does no matter, the resulting error is as follows:
Then astro crashes with the following output:
What's the expected result?
I expect the build to finish without errors. I also expect astro to recognise that it is in a
yarn
environment.Link to Minimal Reproducible Example
In Stackblitz it was impossible to reproduce due to their container limitations. I have added codesandbox, if you cannot access this I can share a GitHub link.
codesandbox
Participation