SBoudrias/Inquirer.js

Error [ERR_REQUIRE_ESM]: require() of ES Module

abhisheksaxenaa opened this issue · 1 comments

I am working on a react native project on Node-18.
Earlier the inquirer was not giving the error until I migrated the project to Node-18.

I am getting

Error [ERR_REQUIRE_ESM]: require() of ES Module
Instead change the require of inquirer.js in /Users/quanteondev/Work/quanteon/nextup-mobile/codepush-release.ts to a dynamic import() which is available in all CommonJS modules.

I am using import to use the inquirer. Not sure what I am doing wrong here.

image

Hi, this is a problem with your tsconfig. It should be modified to output native ESM; not commonjs.

https://2ality.com/2021/06/typescript-esm-nodejs.html