The requested module '__' does not provide an export named '__'
Describe the bug
Ever since updating to the latest SvelteKit my project has had nothing but random error after random error. Sometimes a "SemiColon missing" or "export not provided" or you name it. A meaningless change such as adding a space, removing the space, and rebuilding makes it work -- until I make any changes again, then a new random error shows.
So I decided to just start over from scratch with a fresh folder, new create svelte@latest my-app -- but the issue came up here too. I installed adapter-static npm i -D @sveltejs/adapter-static and npm run build works fine. But when I start the preview server, I get the following:
error when starting preview server:
file:///~/svelte.config.js?ts=1670677968927:1
import adapter from '@sveltejs/adapter-static';
^^^^^^^
SyntaxError: The requested module '@sveltejs/adapter-static' does not provide an export named 'default'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
Note: while this fresh project shows The requested module '@sveltejs/adapter-static' does not provide an export named 'default' - in my original project this would be random. One time it might be adapter-static, but the next it might be The requested module './endpoint.js' does not provide an export named 'is_endpoint_request'
Reproduction
To reproduce:
- Run
create svelte@latest my-appto install SvelteKit (skeleton, TypeScript, no lint, prettier, no Playwright) - Run
npm i -D @sveltejs/adapter-staticfor Adapter Static - Update svelte.config to use adapter static
adapter: adapter({ pages: 'build', assets: 'build', fallback: 'app.html', precompress: true })(the defaults) - Run
npm run buildthennpm run preview
Logs
~MYPROJECTFOLDER % npm run build
> PROJECT build
> vite build
vite v4.0.0 building for production...
✓ 38 modules transformed.
10:28:29 PM [vite-plugin-svelte] dom compile done.
package files time avg
@sveltejs/kit 2 35.2ms 17.6ms
PROJECT 2 28.0ms 14.0ms
vite v4.0.0 building SSR bundle for production...
✓ 45 modules transformed.
10:28:30 PM [vite-plugin-svelte] ssr compile done.
package files time avg
PROJECT 2 6.4ms 3.2ms
@sveltejs/kit 2 3.7ms 1.9ms
Generated an empty chunk: "hooks".
.svelte-kit/output/server/vite-manifest.json 1.27 kB
.svelte-kit/output/server/chunks/hooks.js 0.00 kB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js 0.24 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js 0.32 kB
.svelte-kit/output/server/chunks/paths.js 1.72 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js 3.07 kB
.svelte-kit/output/server/chunks/index.js 3.22 kB
.svelte-kit/output/server/index.js 82.07 kB
Run npm run preview to preview your production build locally.
.svelte-kit/output/client/vite-manifest.json 2.27 kB
.svelte-kit/output/client/_app/immutable/chunks/1-b05b467d.js 0.09 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/chunks/0-04ae84d6.js 0.09 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/chunks/2-ff982b2b.js 0.10 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/components/layout.svelte-cd8f1078.js 0.54 kB │ gzip: 0.36 kB
.svelte-kit/output/client/_app/immutable/components/pages/_page.svelte-84041f18.js 0.83 kB │ gzip: 0.48 kB
.svelte-kit/output/client/_app/immutable/components/error.svelte-bb1aab01.js 2.13 kB │ gzip: 0.98 kB
.svelte-kit/output/client/_app/immutable/chunks/singletons-c1916556.js 2.58 kB │ gzip: 1.34 kB
.svelte-kit/output/client/_app/immutable/chunks/index-7f3551f2.js 6.87 kB │ gzip: 2.79 kB
.svelte-kit/output/client/_app/immutable/start-df02c78a.js 28.29 kB │ gzip: 10.91 kB
> Using @sveltejs/adapter-static
Wrote site to "build"
✔ done
~MYPROJECTFOLDER % npm run preview
> [email protected] preview
> vite preview
error when starting preview server:
file:///~/svelte.config.js?ts=1670678915071:1
import adapter from '@sveltejs/adapter-static';
^^^^^^^
SyntaxError: The requested module '@sveltejs/adapter-static' does not provide an export named 'default'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
System Info
System:
OS: macOS 13.0
CPU: (10) arm64 Apple M1 Max
Memory: 33.77 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.1.0 - /opt/homebrew/bin/node
npm: 8.19.3 - /opt/homebrew/bin/npm
Browsers:
Brave Browser: 108.1.46.138
Chrome: 108.0.5359.98
Safari: 16.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.90
@sveltejs/adapter-static: ^1.0.0-next.49 => 1.0.0-next.49
@sveltejs/kit: next => 1.0.0-next.581
svelte: ^3.54.0 => 3.54.0
vite: ^4.0.0 => 4.0.0
Severity
blocking all usage of SvelteKit
Additional Information
I originally brought this up in Discord: https://discord.com/channels/457912077277855764/1050686836370055218, brought it here when it happened on a fresh setup.
This is preventing me from working on an update to my app that I am supposed to launch in 5 days to my customers. 🥹
I hope it's an easy fix, I am frazzled... no idea what else to try.
Thank you.
Works fine for me with the following envinfo:
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 79.53 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.1.0 - ~/.nvm/versions/node/v19.1.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v19.1.0/bin/npm
Browsers:
Chrome: 108.0.5359.98
Chrome Canary: 110.0.5468.0
Firefox: 107.0.1
Safari: 15.6.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.90
@sveltejs/adapter-static: ^1.0.0-next.49 => 1.0.0-next.49
@sveltejs/kit: next => 1.0.0-next.581
svelte: ^3.54.0 => 3.54.0
vite: ^4.0.0 => 4.0.0
IOW identical package versions, and I installed Node 19.1.0 to verify that wasn't the issue.
Honestly, this doesn't sound like a SvelteKit issue, it sounds like your Node installation is fucked somehow and it's failing to resolve modules. Are you seeing anything similar with other projects?
Ah, I don't have any other projects currently... packed those away some time ago.
But I wouldn't put it past Node being the culprit. Could be a coincidence that it started after an npm update to get the latest SvelteKit.
Interestingly, the errors have gone away "-ish." 😀 By that I mean every once in a while it pops up, but not every time. I can work again, but I feel like I'm coding on eggshells (as if to be extra safe or something lol).
Probably unrelated, but I had to comment out vitePreprocess() in new svelte.config because I was getting Sourcemap for "/~/src/lib/components/COMPONENTNAME.svelte" points to missing source files for every component (below works fine).
preprocess({
postcss: true
})
Bringing it up in case it gives any clues.
Thank you for the reply Rich, I appreciate it. 🙏
Closing as the original issue has been resolved and we can't reproduce it.
For anyone ending up here after searching for
The requested module '@sveltejs/kit/vite' does not provide an export named 'vitePreprocess'
update vitePreprocess import statement to import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
for more info refer https://kit.svelte.dev/docs/migrating-to-sveltekit-2#vitepreprocess-is-no-longer-exported-from-sveltejs-kit-vite
For anyone ending up here after searching for
The requested module '@sveltejs/kit/vite' does not provide an export named 'vitePreprocess'
update vitePreprocess import statement to
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'for more info refer https://kit.svelte.dev/docs/migrating-to-sveltekit-2#vitepreprocess-is-no-longer-exported-from-sveltejs-kit-vite
That was also my problem and your suggestion solved it for me, thank you @Nikhil1920
For anyone ending up here after searching for
The requested module '@sveltejs/kit/vite' does not provide an export named 'vitePreprocess'
update vitePreprocess import statement to
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'for more info refer https://kit.svelte.dev/docs/migrating-to-sveltekit-2#vitepreprocess-is-no-longer-exported-from-sveltejs-kit-vite
Thank youuu!