SvelteKit - failing on import... any ideas?
See original GitHub issue<script>
import Carousel from "svelte-carousel";
</script>
Cannot use import statement outside a module
C:\...\app\node_modules\svelte-carousel\src\main.js:1
import Carousel from './components/Carousel/Carousel.svelte'
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:984:16)
at Module._compile (internal/modules/cjs/loader.js:1032:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at nodeRequire (C:\...\app\node_modules\vite\dist\node\chunks\dep-e9a16784.js:68211:17)
at ssrImport (C:\...\app\node_modules\vite\dist\node\chunks\dep-e9a16784.js:68164:20)
at eval (/src/embed/calc/CalcMortgagePayment.svelte:7:31)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Errors • Docs • SvelteKit
An expected error is one created with the error helper imported from ... An unexpected error is any other exception that occurs while...
Read more >Svelte Kit failed to resolve import "svelte-persistent-store/ ...
It looks like the alternative usage works correctly in SvelteKit: // ❌ fails to resolve // import { writable, readable, derived } from ......
Read more >Doing Advent of Code in SvelteKit. Is it possible to ...
I'm already maintaining this file with the titles of each problem, maybe there's a way to dynamically import and render all the DayXX ......
Read more >Getting Started with SvelteKit: 10 Tips
Want to see what all the buzz is about? Read on to find out how to learn Svelte and also some key tips...
Read more >Solved: Svelte Kit Build Error
js' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When using with SvelteKit do the following:
The official workaround is:
Install it as a dev dependency:
npm install svelte-carousel -D
Import it like this:
How do I use a client-side only library that depends on document or window? why -D ?
FYI: This issue is back on 1.0.17-rc4 (latest as of this writing) Downgrading to 1.0.16 and using the workwaround above still works