withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.11k stars 2.44k forks source link

I wanted to add svelte to astro and I got this error. #9322

Closed YhordiC closed 10 months ago

YhordiC commented 10 months ago

Astro Info

npx astro add svelte
✔ Resolving packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭───────────────────────────────────────────────────╮
 │ npm install @astrojs/svelte svelte@^5.0.0-next.1  │
 ╰───────────────────────────────────────────────────╯

✔ 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:
    /home/yhordi/Documentos/proyectos de yhordi/Spotify-Astro3/spotify-clone/node_modules/astro/dist/cli/add/index.js:175:31
  Code:
    174 |     case 3 /* failure */: {
    > 175 |       throw createPrettyError(new Error(`Unable to install dependencies`));
          |                               ^
      176 |     }
      177 |   }
      178 |   const rawConfigPath = await resolveConfigPath({
  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:///home/yhordi/Documentos/proyectos%20de%20yhordi/Spotify-Astro3/spotify-clone/node_modules/astro/dist/cli/add/index.js:175:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runCommand (file:///home/yhordi/Documentos/proyectos%20de%20yhordi/Spotify-Astro3/spotify-clone/node_modules/astro/dist/cli/index.js:102:7)
    at async cli (file:///home/yhordi/Documentos/proyectos%20de%20yhordi/Spotify-Astro3/spotify-clone/node_modules/astro/dist/cli/index.js:144:5)

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

en ninguno

Describe the Bug

I can't install svelte dependencies and packages on astro

What's the expected result?

bunx astro add svelte Installing dependencies... Astro will generate a minimal ./svelte.config.js file. Continue? ... yes Astro will make the following changes to your config file: astro. config.mjs import { defineConfig } from 'astro/config'; import tailwind from "@astrojs/tailwind"; import svelte from "@astrojs/svelte"; // https://astro.build/config export default defineConfig({ integrations: [tailwindO), svelte()], output: 'server' )); ? Continue? > (Y/n)

Link to Minimal Reproducible Example

https://github.com/YhordiC/spotify-clone

Participation

matthewp commented 10 months ago

Just a complete guess, but could you try in a folder that doesn't have a space?

ElianCodes commented 10 months ago

Maybe just a copy paste error, but I see an extra O added to tailwindO, but you're importing import tailwind from "@astrojs/tailwind";

// yours
integrations: [tailwindO), svelte()],

// should be
integrations: [tailwind(), svelte()],
YhordiC commented 10 months ago

I've already solved the problem, to fix the error I had to import Svelte to Astro manually. The information and procedure can be found in the documentation on the official website of AstroJs [Link of the website] Another problem I had was with the version of Astro that gave me compatibility problems, so I installed Svelte with a specific version compatible with the version of Astro I had installed.

To change the version of Astro modify it in the packege.json, and then use the npm install command; To install a specific version of Svelte use the following npm install @astrojs/svelte@"Version" command. Thank you for taking the time to comment and try to help.