question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directory import is not supported resolving ES modules imported /.svelte/output/server/app.js

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
samcconecommented, Mar 29, 2021

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.

3reactions
benleshcommented, Mar 30, 2021

Thanks to @samccone, that fix is in and deployed in rxjs@7.0.0-beta.14.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Directory import is not supported resolving ES modules' with ...
With ES6 modules you can not (yet?) import directories. Your import should look like this: import database from "./database/index.js".
Read more >
Node.js – 'Directory import is not supported resolving ES ...
Node.js – 'Directory import is not supported resolving ES modules' with Node.js ... I'm using Node.js v14.13.0. app.js file: import database from './database'; ......
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
This setting controls whether .js files are interpreted as ES modules or CommonJS modules, and defaults to CommonJS when not set. When a...
Read more >
SvelteKit + Sveltestrap? : r/sveltejs - Reddit
Directory import 'C:\dev\javascript\svelte-sapper\svelte-kit-test\node_modules\ ... is not supported resolving ES modules imported from ...
Read more >
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep ... uses a different pattern or method for resolving file imports....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found