cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
232 stars 42 forks source link

[cubing.js issue] Couldn't find package.json for cubing Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in node_modules/cubing/package.json #236

Closed cohenerickson closed 1 year ago

cohenerickson commented 1 year ago

Steps to reproduce the issue

  1. Try to use cubing.js in a project being built by vite

Observed behaviour

Couldn't find package.json for cubing Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in node_modules/cubing/package.json
    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:748:3)
    at resolveExports (node:internal/modules/cjs/loader:493:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at file:///workspaces/Solid-Timer/node_modules/vite-plugin-solid/dist/esm/index.mjs:53:35
    at Array.map (<anonymous>)
    at getSolidDeps (file:///workspaces/Solid-Timer/node_modules/vite-plugin-solid/dist/esm/index.mjs:48:21) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Expected behaviour

No Error.

Environment

Cubing.js Version: ^0.31.0 NodeJS Version: v16.17.1 Vite Version: ^3.1.0

🖼 Screenshots

No response

Additional info

Seems like this might be related to #198 The repository for my project is https://github.com/cohenerickson/Solid-Timer and the file that I am importing cubing from is "src/data.ts".

lgarron commented 1 year ago

Thanks for filing an issue with a repro repo!

This probably isn't the same as #198, but not all bundlers handle exports properly. I'll take a look.

lgarron commented 1 year ago

The issue is in vite-plugin-solid, which is making a bad assumption at https://github.com/solidjs/vite-plugin-solid/blob/5558486b0c63788e1275244256918f80294a8338/src/index.ts#L275 I'll file an issue with them.

lgarron commented 1 year ago

Reported at https://github.com/solidjs/vite-plugin-solid/issues/66

That also contains a fix you can hack into your node_modules/vite-plugin-solid/dist/esm/index.mjs (near line 57), if you just want to get things working for now.

I'm quite certain that there is nothing to fix in cubing.js, so I'm going to close this issue for now. Feel free to comment or open a new issue if you run into more trouble.

cohenerickson commented 1 year ago

Sorry for the late response, thanks for digging into this, the solution you provided is working for the time being.