Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_REQUIRE_ESM with jiti/register #355

Open
yshrsmz opened this issue Dec 23, 2024 · 0 comments
Open

ERR_REQUIRE_ESM with jiti/register #355

yshrsmz opened this issue Dec 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@yshrsmz
Copy link

yshrsmz commented Dec 23, 2024

Environment

OS: Mac Sequoia 15.2
Node.js: 20.18.1
Package Manager: [email protected]
jiti: 2.4.2
TypeScript: 5.7.2
Fastify: 5.2.0

Reproduction

https://github.com/yshrsmz/jiti-watch-test

Describe the bug

When running Fastify app with node --import jiti/register src/index.ts, it throws an ERR_REQUIRE_ESM error.

I couldn't reproduce the error when I directly used thread-stream(it might be because I didn't fully understand thread-stream), so the repro has a bit big dependency.

Additional context

No response

Logs

$ pnpm dev

> [email protected] dev /Users/yshrsmz/repos/github.com/yshrsmz/jiti-watch-test
> JITI_DEBUG=1 node --watch --import jiti/register src/index.ts

[jiti] [init] version: 2.4.2 module-cache: true fs-cache: true interop-defaults: true
[jiti] [cache] [hit] ./src/index.ts ~> ./node_modules/.cache/jiti/src-index.c030801c.mjs
[jiti] [init] version: 2.4.2 module-cache: true fs-cache: true interop-defaults: true
[jiti] [native] [import] ./node_modules/.pnpm/[email protected]/node_modules/fastify/fastify.js
[jiti] [cache] [hit] ./node_modules/.pnpm/[email protected]/node_modules/fastify/fastify.js ~> ./node_modules/.cache/jiti/fastify-fastify.26d881ec.mjs
[jiti] Native import error: {"code":"ERR_REQUIRE_ESM"}
[jiti] [fallback] ./node_modules/.pnpm/[email protected]/node_modules/fastify/fastify.js
[jiti] [cache] [hit] ./node_modules/.pnpm/[email protected]/node_modules/fastify/fastify.js ~> /var/folders/0w/sff60qpj5b39qk2mt2b6rdc43l5srr/T/jiti/fastify-fastify.26d881ec.mjs
[jiti] [transpile] [esm] ./node_modules/.pnpm/[email protected]/node_modules/fastify/fastify.js (0.497ms)
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/schema-controller.js
[jiti] Native require error: {}
[jiti] [fallback] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/schema-controller.js
[jiti] [cache] [hit] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/schema-controller.js ~> /var/folders/0w/sff60qpj5b39qk2mt2b6rdc43l5srr/T/jiti/lib-schema-controller.cf868271.cjs
[jiti] [native] [require] ./node_modules/.pnpm/@[email protected]/node_modules/@fastify/fast-json-stringify-compiler/index.js
[jiti] [native] [require] ./node_modules/.pnpm/@[email protected]/node_modules/@fastify/ajv-compiler/index.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/pluginUtils.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/reqIdGenFactory.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/route.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/fourOhFour.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/initialConfigValidation.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/pluginOverride.js
[jiti] [native] [require] ./node_modules/.pnpm/[email protected]/node_modules/fastify/lib/noop-set.js
node:internal/modules/esm/loader:568
      throw new ERR_REQUIRE_ESM(url, true);
            ^

Error [ERR_REQUIRE_ESM]: require() of ES Module file:///Users/yshrsmz/repos/github.com/yshrsmz/jiti-watch-test/node_modules/.pnpm/[email protected]/node_modules/thread-stream/package.json not supported.
    at Object.<anonymous> (/Users/yshrsmz/repos/github.com/yshrsmz/jiti-watch-test/node_modules/.pnpm/[email protected]/node_modules/thread-stream/index.js:3:21) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.18.1
Failed running 'src/index.ts'
@yshrsmz yshrsmz added the bug Something isn't working label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant