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

ERR_PACKAGE_PATH_NOT_EXPORTED when package is called using import.meta.resolve #150

Open
2 tasks done
thescientist13 opened this issue Dec 9, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@thescientist13
Copy link

thescientist13 commented Dec 9, 2024

Font Name (Geist Sans/Geist Mono):

  • Geist Sans
  • Geist Mono

Description of the Issue:

When providing this package's specifier to import.meta.resolve NodeJS throws a ERR_PACKAGE_PATH_NOT_EXPORTED error

➜  import-meta-resolve-geist git:(master) ✗ node index.js 
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/owenbuckley/Workspace/github/import-meta-resolve-geist/node_modules/geist/package.json imported from /Users/owenbuckley/Workspace/github/import-meta-resolve-geist/index.js
    at exportsNotFound (node:internal/modules/esm/resolve:304:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:651:9)
    at packageResolve (node:internal/modules/esm/resolve:837:14)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolveSync (node:internal/modules/esm/loader:524:17)
    at Object.resolve (node:internal/modules/esm/initialize_import_meta:30:25)
    at file:///Users/owenbuckley/Workspace/github/import-meta-resolve-geist/index.js:2:32
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Steps to Reproduce:

  1. Run import.meta.resolve('geist')

You can see a full reproduction repo here - https://github.com/thescientist13/import-meta-resolve-geist

Expected Behavior:

That the call to import.meta.resolve would return a path to the package's entrypoint, e.g. file:///path/to/node_modules/geist/dist/font.js

Screenshots:
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: MacOS
  • Software: Node 20.x
  • Version of the Font: 1.3.1

Additional Context:

The solution for this to define a default entry point in the exports map, which seems like just using the package's current module entry point value

{
  "module": "./dist/font.js",
  "exports": {
    ".": "./dist/font.js",
    "./font": {
      "types": "./dist/index.d.ts",
      "default": "./dist/font.js"
    },
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant