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

Import does not work #677

Closed
raxod502 opened this issue Feb 27, 2024 · 7 comments
Closed

Import does not work #677

raxod502 opened this issue Feb 27, 2024 · 7 comments

Comments

@raxod502
Copy link

When installing the latest version of the package in a new package.json with Node.js 20 LTS following the directions in the README:

% npm i @octokit/plugin-throttling

added 12 packages, and audited 13 packages in 937ms

found 0 vulnerabilities

% node
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> require("@octokit/plugin-throttling")
Uncaught:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /home/raxod502/files/temp/example-repo/node_modules/@octokit/plugin-throttling/package.json
    at exportsNotFound (node:internal/modules/esm/resolve:303:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:593:13)
    at resolveExports (node:internal/modules/cjs/loader:591:36)
    at Module._findPath (node:internal/modules/cjs/loader:668:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

See also vercel/ncc#1167.

@gr2m
Copy link
Contributor

gr2m commented Feb 27, 2024

feels more like a bug with ncc than with the package? require("@octokit/plugin-throttling") doesn't work because it's an ESM module now, try import("@octokit/plugin-throttling")

@wolfy1339
Copy link
Member

Other users have experienced issues where tooling cannot find the module, and adding in a main field has helped them
See octokit/core.js#662

@raxod502
Copy link
Author

raxod502 commented Feb 27, 2024

If require does not work, should the documentation (which says to use require) be updated?

image

@raxod502
Copy link
Author

feels more like a bug with ncc than with the package?

Note that ncc is not involved in the bug report here; I simply installed the package through NPM and tried to load it with require.

@wolfy1339
Copy link
Member

Yes, the docs need updating, but again, you should read the release notes as you seem to be upgrading this package

@wolfy1339
Copy link
Member

Fixed by #679

@raxod502
Copy link
Author

Thanks - I expect this will save people a lot of time with troubleshooting in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants