Skip to content

Cannot Use with an ESM project  #14

Description

@NickPadilla

I was playing around with this project, see if could get some docs built out for some open source. However, I could not get it to run as I am getting this error:

npx code-narrator
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/box/structures/structures-js/structures-api/code-narrator.config.js from /Users/box/.npm/_npx/e378fa2a901701d1/node_modules/code-narrator/dist/src/utils/CliHelper.js not supported.
Instead change the require of code-narrator.config.js in /Users/box/.npm/_npx/e378fa2a901701d1/node_modules/code-narrator/dist/src/utils/CliHelper.js to a dynamic import() which is available in all CommonJS modules.
    at /Users/box/.npm/_npx/e378fa2a901701d1/node_modules/code-narrator/dist/src/utils/CliHelper.js:73:96
    at async CliHelper.getConfig (/Users/box/.npm/_npx/e378fa2a901701d1/node_modules/code-narrator/dist/src/utils/CliHelper.js:73:30)
    at async /Users/box/.npm/_npx/e378fa2a901701d1/node_modules/code-narrator/dist/src/cli.js:12:22 {
  code: 'ERR_REQUIRE_ESM'
}

This is the folder within the open source I am trying to test this against. https://github.com/Kinotic-Foundation/structures/tree/main/structures-js/structures-api

I did need to modify the code-narrator.config.js to use import statements and not use require to get past the first error.

I believe using vite might be a better build tool, as it should allow building for both CommonJS and ESM. If I find the time, I might play around with this and see if can get it to work.. just don't have the time right now.

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