Skip to content

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

@gustawdaniel

Description

@gustawdaniel

I am using ts-node and see

➜ npx ts-node src/index.ts I need list files in directory
/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/index.js:851
            return old(m, filename);
                   ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/daniel/pro/gpt-cli/node_modules/@inquirer/confirm/dist/index.js from /home/daniel/pro/gpt-cli/src/index.ts not supported.
Instead change the require of index.js in /home/daniel/pro/gpt-cli/src/index.ts to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/index.js:851:20)
    at Object.<anonymous> (/home/daniel/pro/gpt-cli/src/index.ts:18:35)
    at m._compile (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/index.js:859:16)
    at phase4 (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/bin.js:466:20)
    at bootstrap (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/bin.js:54:12)
    at main (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/bin.js:33:12)
    at Object.<anonymous> (/home/daniel/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/dist/bin.js:579:5) {
  code: 'ERR_REQUIRE_ESM'
}

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