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 #88

Closed
jeremythille opened this issue Aug 15, 2023 · 1 comment
Closed

ERR_REQUIRE_ESM #88

jeremythille opened this issue Aug 15, 2023 · 1 comment

Comments

@jeremythille
Copy link

I'm using (as per the doc) :

import { serializeError } from 'serialize-error';

When executing my script, it crashes with this error :

Error [ERR_REQUIRE_ESM]: require() of ES Module /media/sf_NPL/core/node_modules/serialize-error/index.js from /media/sf_NPL/core/imports/manager/imports/log.ts not supported.
Instead change the require of index.js in /media/sf_NPL/core/imports/manager/imports/log.ts to a dynamic import() which is available in all CommonJS modules.
    at Object.require.extensions.<computed> [as .js] (/home/jer/.nvm/versions/node/v16.20.2/lib/node_modules/ts-node/dist/index.js:851:20)
    at Object.<anonymous> (/media/sf_NPL/core/imports/manager/imports/log.ts:28:27)
    at Module.m._compile (/home/jer/.nvm/versions/node/v16.20.2/lib/node_modules/ts-node/dist/index.js:857:29)
    at Object.require.extensions.<computed> [as .ts] (/home/jer/.nvm/versions/node/v16.20.2/lib/node_modules/ts-node/dist/index.js:859:16)
    at new Manager (/media/sf_NPL/core/imports/manager/index.ts:15:20)
    at /media/sf_NPL/core/index.ts:80:19 {
  code: 'ERR_REQUIRE_ESM'
}

I'm getting the same error if I use instead :

const serializeError = require('serialize-error')

I write Typescript code which is then executed with ts-node myscript.ts.

Versions :
node 16.20.2
serialize-error ^11.0.1
ts-node 10.9.1

@sindresorhus
Copy link
Owner

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants