Error [ERR_REQUIRE_ESM]: require() of ES
See original GitHub issueError [ERR_REQUIRE_ESM]: require() of ES Module /var/runtime/app/node_modules/serialize-error/index.js from /var/runtime/app/src/webhooks/sendgrid.ts not supported. Instead change the require of index.js in [redacted] to a dynamic import() which is available in all CommonJS modules.
import { serializeError } from 'serialize-error';
tsconfig:
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"outDir": "dist",
"skipLibCheck": true,
"strict": true,
"target": "ES2020",
"lib": ["esnext"]
},
"exclude": [
"infrastructure/**/*.ts",
"test/**/*.ts"
]
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >Must use import to load ES Module / require() of ES ... - GitHub
I have suddenly started getting the following error: $ npm test > geodesy@2.2.0 test /home/travis/build/chrisveness/geodesy > mocha --exit ...
Read more >ERR_REQUIRE_ESM - DEV Community
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ~/projects/semantic-release-toolkit/node_modules/zz/cjs.js require() of ES ...
Read more >Error ERR REQUIRE ESM | Must use import to load ES Module
Error ERR REQUIRE ESM | Must use import to load ES Module. 15K views 1 year ago JS - JavaScript · Sagar S....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Works downgrading to 8.1.0
Hi everyone
This part of
tsconfig.json
is probably the cause of the error. It has to benode16
, notcommonjs
.You also need to set
"moduleResolution": "node16"
as well.This is explained in the link given by Sindre above. Here’s a quote: