kit: adapter-static fails with ESM config
npm 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?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (15 by maintainers)
Just bit by this myself. I had
const staticin the file, andstaticis a reserved word. Replace all reserved words in the file and hopefully everything will work.Is there a reason for
adapter-staticto 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
#936 was a pre-requisite for the upcoming work to publish the adapters as ESM. Until that’s done it’s probably better to continue using
.cjs, though if you really want to use ESM config you should be able to do this: