Directory import is not supported resolving ES modules imported /.svelte/output/server/app.js
See original GitHub issueDescribe the bug
When running npm run build
on a project that uses RxJS I get the following error:
Directory import ‘/Users/evert/Sites/svelte-kit-tailwind-jit/node_modules/rxjs/operators’ is not supported resolving ES modules imported from /Users/evert/Sites/svelte-kit-tailwind-jit/.svelte/output/server/app.js Did you mean to import rxjs/dist/cjs/operators/index.js?
If I indeed manually change that line in /.svelte/output/server/app.js
from this:
import {share, filter, map, finalize} from "rxjs/operators";
To this:
import {share, filter, map, finalize} from "rxjs/dist/cjs/operators/index.js";
then I can successfully run npm run start
and everything works.
To Reproduce
Just install RxJS and import some operators somewhere. I tested this on kit version 1.0.0-next.55
.
Expected behavior This to just work without a hitch.
Stacktrace
Stack trace
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import ‘/Users/evert/Sites/svelte-kit-tailwind-jit/node_modules/rxjs/operators’ is not supported resolving ES modules imported from /Users/evert/Sites/svelte-kit-tailwind-jit/.svelte/output/server/app.js Did you mean to import rxjs/dist/cjs/operators/index.js? at new NodeError (node:internal/errors:329:5) at finalizeResolution (node:internal/modules/esm/resolve:319:17) at moduleResolve (node:internal/modules/esm/resolve:758:10) at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:869:11) at Loader.resolve (node:internal/modules/esm/loader:86:40) at Loader.getModuleJob (node:internal/modules/esm/loader:230:28) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:57:40) at link (node:internal/modules/esm/module_job:56:36)
Information about your SvelteKit Installation:
The output of `npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers`
System: OS: macOS 11.2.3 CPU: (8) x64 Apple M1 Memory: 19.48 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.8.0 - ~/.nvm/versions/node/v15.8.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v15.8.0/bin/yarn npm: 7.6.1 - ~/.nvm/versions/node/v15.8.0/bin/npm Browsers: Chrome: 89.0.4389.90 Safari: 14.0.3 npmPackages: @sveltejs/kit: ^1.0.0-next.55 => 1.0.0-next.55 svelte: ^3.29.0 => 3.35.0
-
My browser: Chrome
-
My adapter: adapter-node
Severity
For now I’m just playing around with SvelteKit. So it’s okay with me if I can’t run npm run build
as long as I can run npm run dev
, which for now seems to be working fine.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:18 (7 by maintainers)
Top GitHub Comments
Hi all, I have a fix for rxjs https://github.com/ReactiveX/rxjs/pull/6192
IMHO this is not a problem with sveltekit, and rather is a challenge with the node ecosystem. Since sveltekit is using
package: module
I expect we are going to continue to see this class of problem moving forward.The path for fixing things is going to be to send PRs upstream to your libraries to fix.
@Rich-Harris @benmccann +1 to close this issue imho.
Thanks to @samccone, that fix is in and deployed in
rxjs@7.0.0-beta.14
.