node-gitlog icon indicating copy to clipboard operation
node-gitlog copied to clipboard

require() of ES Module node_modules/gitlog/dist/index.js from xx.js not supported.

Open batchor opened this issue 1 year ago • 3 comments

I run into this weird error. I'm not familiar with ts but it seems like some import problem with this package because all other packages are working well.

What I have in my sdk/git_cli/index.ts is:

import gitlog, { GitlogOptions } from "gitlog";

tsconfig.ts:

{
    "compilerOptions": {
      "module": "CommonJS",
      "esModuleInterop": true,
      "target": "ES2022",
      "allowJs": true,
      "removeComments": true,
      "lib": [
        "ES2022.String",
        "ES2022"
      ],
      "moduleResolution": "Node",
      "sourceMap": true,
      "skipLibCheck": true,
      "outDir": "dist",
    },
    "exclude": [
        "node_modules",
        "frontend",
        "test",
        "dist"
    ],
}

batchor avatar Aug 03 '24 23:08 batchor

Hey! What's the error you're seeing?

domharrington avatar Aug 05 '24 10:08 domharrington

Hey! What's the error you're seeing?

The error message is in the title:

Error [ERR_REQUIRE_ESM]: require() of ES Module /scienhub/node_modules/gitlog/dist/index.js from xx.js not supported.

where xx.js is my ts code transpiled into CommonJS.

batchor avatar Dec 05 '24 23:12 batchor

Are you able to open up a minimal reproduction repo that I can checkout to debug this?

domharrington avatar Dec 10 '24 10:12 domharrington