adapter-static fails with ESM config
See original GitHub issuenpm init svelte@next test-esm-static
cd test-esm-static
mv svelte.config.cjs svelte.config.js
yarn add -D @sveltejs/kit@next @sveltejs/adapter-static@next
and changing the contents of svelte.config.js
to
import adapter from "@sveltejs/adapter-static";
export default {
adapter: adapter(),
kit: {
target: "#svelte",
},
};
followed by svelte-kit (dev|build)
throws
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in node_modules/@sveltejs/adapter-static/package.json imported from svelte.config.js
at new NodeError (node:internal/errors:363:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:321:9)
at packageExportsResolve (node:internal/modules/esm/resolve:510:7)
at packageResolve (node:internal/modules/esm/resolve:687:14)
at moduleResolve (node:internal/modules/esm/resolve:739:18)
at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)
at Loader.resolve (node:internal/modules/esm/loader:89:40)
at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:73:40)
at link (node:internal/modules/esm/module_job:72:36)
I was expecting this to work now that #936 is merged but looks like the adapters still need updating?
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
node.js - SvelteKit build throws ESM module error in ...
Tested with the standard SvelteKit demo app and addition of adapter-node in the config as per usual: import adapter from '@sveltejs/adapter-node ...
Read more >@sveltejs/adapter-static | Yarn - Package Manager
Adapter for SvelteKit apps that prerenders your entire site as a collection of static files. If you'd like to prerender only some pages,...
Read more >ECMAScript Modules - Jest
Jest ships with experimental support for ECMAScript Modules (ESM). The implementation may have bugs and lack features. For the latest status ...
Read more >: unknown file extension ".ts" | The AI Search Engine You Control
I'm having the same issue. λ npx ts-node src/app.ts TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for C:\Users\$USER ...
Read more >[ERR_MODULE_NOT_FOUND] Cannot find module ... - Reddit
Using @sveltejs/adapter-static > Cannot find module ... Did you mean to import @popperjs/core/dist/esm/popper.js? Error ...
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 FreeTop 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
Top GitHub Comments
Just bit by this myself. I had
const static
in the file, andstatic
is a reserved word. Replace all reserved words in the file and hopefully everything will work.Is there a reason for
adapter-static
to exist as a separate package, vs encouraging users to roll their own? For example:That’s likely due to a bug in Svelte 3.38.0 and 3.38.1 — should be fixed in 3.38.2