-
Notifications
You must be signed in to change notification settings - Fork 310
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]: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in #667
[BUG]: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in #667
Comments
👋 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 |
Please share reproducible code example |
That specific error message suggest you are not using ESM. Please see the usage section in the README: |
Hi, I have the same issue.
Octokit.js: v6.0.1 I already use ESM to import the Octokit class: |
Are you using typescript at all? In typescript just because you are importing using ESM imports doesn't mean you are using ESM |
If anyone is experiencing this issue, please give a small reproducible example in a separate repo. Include the Also don't forget to specify the environment (Browser/Node/Deno as well as the version) It would be very helpful in diagnosing this issue and helping out users. You may also want to read up on ESM packages, https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
Anyone found a workaround for this, i'm also experiencing same issue |
@iamnotstatic Please read my comment above. |
@wolfy1339 https://github.com/Darker935/MdgWa-TEST Run with |
@Darker935 Also, you are still using CJS in your example which explains some of the errors |
Downgrading to |
I understand that downgrading has solved the issue, I really wish to diagnose and fix this issue for users |
Okay, this was my initial config
tsconfig
|
You are using CJS and not ESM. You will need to use dynamic imports or upgrade to ESM
|
Alright thanks @wolfy1339 |
@wolfy1339 I'm getting the same error and others, setting to ESM or "node16" in tsconfig
Results in:
With:
Case package.json type = "module":
Without package.json type = "module":
With:
Results in:
My default tsconfig.json file:
I'm using "@octokit/core": "^6.0.1" and Node v18.17.0
|
You can use dynamic imports, upgrade your code to ESM, or stick with v5 Option 1: async function main() {
const { Octokit } = await import('@octokit/core');
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
}
main(); Option 2: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Option 3:
The error in question in this issue is people that their code is CJS and are importing an ESM module. There is also bugs with At this point, there is nothing actionable on our part. This is user error |
@wolfy1339 I don't think this should've been closed out. The resolution would be to add to all octokit ".": {
"default": "path/to/entry.js"
} So many packages I've seen in the wild omit |
From how I interpret the documentation, Do you have an explanation as to why thus isn't the case? |
@wolfy1339 I've seen this happen in @JoaoScheleder @iamnotstatic @IchanZX1 @clementhemidy "exports": {
".": {
"types": "./dist-types/index.d.ts",
- "import": "./dist-src/index.js"
+ "import": "./dist-src/index.js",
+ "default": "./dist-src/index.js"
}
}, |
@jeremy-daley-kr
And it did help, but i was still getting an error. Important what helped me was switching from nodemon and ts-node to tsx.
|
What happened?
How To fix?
Versions
Octokit.js v6.0.1, Node v18.19.1
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: