language-tools: Svelte is not a module with "astro@latest -- --template framework-svelte"
Astro Info
Astro v4.3.5
Node v20.11.0
System Windows (x64)
Package Manager npm
Output static
Adapter none
Integrations @astrojs/svelte
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Hey!
I want to use “astro@latest – --template framework-svelte” but when I run “npm run build” I have an error message that explains:
src/pages/index.astro:3:21 - error ts(2306): File ‘C:/Users/Utilisateur/Desktop/astrosvelte/src/components/Counter.svelte’ is not a module.
Is the @astrojs/svelte
package installed? You can add it to your project by running the following command: astro add svelte
. If already installed, restarting the language server might be necessary in order for the change to take effect.
import Counter from ‘…/components/Counter.svelte’;
I have installed my dependencies correctly, and @astrojs/svelte is indeed in my node_modules, and I haven’t touched the default settings.
I have tested with other templates, and React and Vue do not pose any problems.
Setup :
IDE : VS Code + Extension Astro & Svelte Node : v20.11.0 NPM : 10.2.4
What’s the expected result?
I want to import Svelte components in .astro and build my app.
Link to Minimal Reproducible Example
https://github.com/withastro/astro/tree/main/examples/framework-svelte
Participation
- I am willing to submit a pull request for this issue.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 2
- Comments: 18 (9 by maintainers)
Fixed by https://github.com/withastro/language-tools/pull/791
Can reproduce on Windows, WSL and other integrations like React don’t have this error
Astro v4.3.5 Node v20.10.0 System Windows (x64) Package Manager pnpm Output static Adapter none Integrations @astrojs/svelte
There was a similar issue with Vue, I transferred it to the language-tools repo. Can’t do it rn (on phone)
I have the same problem.
Astro Info:
IDE: VS Code
VS Code info:
relevant extensions installed:
https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode
package.json:
astro.config.mjs:
svelte.config.js
Error message:
File ‘c:/Users/username/Documents/projects/my-app/src/components/authComponents/RegisterForm.svelte’ is not a module.
Is the
@astrojs/svelte
package installed? You can add it to your project by running the following command:astro add svelte
. If already installed, restarting the language server might be necessary in order for the change to take effect.