Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
rs-duongnt1 opened this issue May 14, 2024 · 5 comments
Closed
1 task done
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@rs-duongnt1
Copy link

rs-duongnt1 commented May 14, 2024

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

  • I agree to follow this project's Code of Conduct
@rs-duongnt1 rs-duongnt1 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 14, 2024
Copy link

👋 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 wolfy1339 added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Type: Bug Something isn't working as documented Status: Triage This is being looked at and prioritized labels May 14, 2024
@wolfy1339
Copy link
Member

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

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

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active May 14, 2024
@suka233
Copy link

suka233 commented May 15, 2024

same error

@itspers
Copy link

itspers commented Aug 12, 2024

This modern web is something crazy.
Its not "issue with NestJS. They don't have support for ESM" - its issue with this library. Other libs work - this one dont. Github monopolized it, there are no alternatives and it just cant work not in hello-world nodejs app with express and react.

@wolfy1339
Copy link
Member

It is not an issue with this library. We don't do CJS builds anymore.

NestJS doesn't support ESM as I've linked to above.

The error given means that you are trying to import an ESM library using CJS require().

It is not an issue on our side. Other libraries might still have support for CJS, we decided to switch to ESM only.

Please read the changelog and previous issues before posting on an old resolved issue.

Simply use an older version of Octokit that still has CJS support.

@octokit octokit locked and limited conversation to collaborators Aug 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
Archived in project
Development

No branches or pull requests

4 participants