octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
6.83k stars 1k forks source link

[BUG]: [Nestjs] [ERR_REQUIRE_ESM]: require() of ES Module not supported #2680

Closed rs-duongnt1 closed 1 month ago

rs-duongnt1 commented 1 month ago

What happened?

import { Octokit, App } from 'octokit';
const app = new App({
      appId: 'APP_ID',
      privateKey: this.getPrivateKey(),
});

Throw error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported. in nestjs framework.

I have change it below, but it not working in nestjs.

As we use conditional exports, you will need to adapt your tsconfig.json by setting "moduleResolution": "node16", "module": "node16".

Versions

Latest

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 1 month ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

wolfy1339 commented 1 month ago

This seems like an issue with NestJS. They don't have support for ESM

A quick search yields https://github.com/nestjs/nest/issues/7021 https://stackoverflow.com/questions/74830166/unable-to-import-esm-module-in-nestjs

suka233 commented 1 month ago

same error