`ERR_PACKAGE_PATH_NOT_EXPORTED` due to bad assumptions in dependency resolution
Closed this issue · 0 comments
lgarron commented
npm init solid repro # use default settings for config prompts
cd repro
npm install
npm install --save-dev cubing
npm run build
Expected: no crrash
Observed: even with no code changes, this runs into:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in [path to project]/node_modules/cubing/package.json
Specifically, the error happens due to this line:
vite-plugin-solid/src/index.ts
Line 275 in 5558486
package.json
definitely exists in the cubing
package. I have two guesses for why this is running into an issue:
cubing
is ESM-only, but the code is usingrequire.resolve
.- The code is assuming that
cubing
can be imported directly, but it only has exports one level down (e.g.cubing/alg
): https://github.com/cubing/cubing.js/blob/a2b56969ca6ed4d9488aebecb834def54b6c290b/package.json#L9-L54
Someone is trying to use our library with vite-plugin-solid
(cubing/cubing.js#236), and I'd appreciate if you could fix this for them. One fix that worked for me locally is replace the bad line with resolve
from node:path
:
// Added import
import { resolve } from "node:path";
// Replaced line
dir = dirname(resolve(dep));