Skip to content

Error ERR_REQUIRE_ESM when using it with inquirer@v9 #88

@DerZyklop

Description

@DerZyklop

I recently got this error when trying to run npx ntl --autocomplete:

/[project path]/node_modules/inquirer-autocomplete-prompt-ipt/index.js:10
var Base = require('inquirer/lib/prompts/base');
           ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /[project path]/node_modules/inquirer/lib/prompts/base.js from /[project path]/node_modules/inquirer-autocomplete-prompt-ipt/index.js not supported.
Instead change the require of base.js in /[project path]/node_modules/inquirer-autocomplete-prompt-ipt/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/[project path]/node_modules/inquirer-autocomplete-prompt-ipt/index.js:10:12) {
  code: 'ERR_REQUIRE_ESM'
}

I tried to debug without knowing much about the internals of ntl, and figured out:

  • It’s not a problem when I run the globally installed ntl, its only a problem when ntl is installed in my project folder.
  • It's not a problem when I add "inquirer": "8" to my package.json. Otherwise version 9 would be installed/used.

Hope this helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions