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 add fails when in a npm workspace #7925

Closed
1 task
rverton opened this issue Aug 2, 2023 · 3 comments · Fixed by #9593
Closed
1 task

astro add fails when in a npm workspace #7925

rverton opened this issue Aug 2, 2023 · 3 comments · Fixed by #9593
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: add Related to `astro add` CLI command (scope)

Comments

@rverton
Copy link

rverton commented Aug 2, 2023

What version of astro are you using?

2.9.6

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

None

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

When I use Astro in a npm workspace, adding integrations via astro add fails.

  1. npm init
  2. npm init -w ./packages/web
  3. rm ./packages/web/package.json (so create-astro can run in an empty folder)
  4. cd ./packages/web/ && npx create-astro@latest and confirm each question
  5. npm run astro add tailwind

This results in:

✔ Continue? … yes
✖ Installing dependencies...
 error   Astro could not update your astro.config.js file safely.
  Reason: Unable to install dependencies

  You will need to add these integration(s) manually.
  Documentation: https://docs.astro.build/en/guides/integrations-guide/
  File:
    /private/tmp/astro-workspaces/node_modules/astro/dist/cli/add/index.js:170:31
  Code:
    169 |     case 3 /* failure */: {
    > 170 |       throw createPrettyError(new Error(`Unable to install dependencies`));
          |                               ^
      171 |     }
      172 |   }
      173 |   const rawConfigPath = await resolveConfigPath({ cwd, flags, fs: fsMod });
  Stacktrace:
Error: Astro could not update your astro.config.js file safely.
Reason: Unable to install dependencies

You will need to add these integration(s) manually.
Documentation: https://docs.astro.build/en/guides/integrations-guide/
    at add (file:///private/tmp/astro-workspaces/node_modules/astro/dist/cli/add/index.js:170:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runCommand (file:///private/tmp/astro-workspaces/node_modules/astro/dist/cli/index.js:103:7)
    at async cli (file:///private/tmp/astro-workspaces/node_modules/astro/dist/cli/index.js:155:5)

This may be related to #3071.

What's the expected result?

The integration is added without any error.

Link to Minimal Reproducible Example

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 Aug 2, 2023
@natemoo-re natemoo-re added the - P3: minor bug An edge case that only affects very specific usage (priority) label Aug 3, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 3, 2023
@natemoo-re natemoo-re added the feat: add Related to `astro add` CLI command (scope) label Aug 3, 2023
@justindra
Copy link

justindra commented Aug 11, 2023

Just adding some more info here as just ran into this issue when using the pnpm astro add tailwind command.

What version of astro are you using?
2.10.6

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

What package manager are you using?
pnpm

What operating system are you using?
Ubuntu (WSL2 on Windows)

What browser are you using?
Chrome

@rishi-raj-jain
Copy link
Contributor

Related #8487

@bluwy
Copy link
Member

bluwy commented Jan 3, 2024

The core issue is an upstream issue at zkochan/packages#180 and I made a fix at zkochan/packages#183. However the CLI didn't quite reported the issue nicely so I'll make a fix to surface that better as the solution for now. When the upstream PR is merged, this should also be fixed automatically.

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) feat: add Related to `astro add` CLI command (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants