SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.23k stars 1.3k forks source link

Error [ERR_REQUIRE_ESM]: require() of ES Module #1308

Closed abhisheksaxenaa closed 1 year ago

abhisheksaxenaa commented 1 year ago

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

SBoudrias commented 1 year ago

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