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

./node_modules/shpjs/lib/unzip.js Module not found: Can't resolve 'but-unzip' in '<myfolder>/node_modules/shpjs/lib' #217

Open
ahalota opened this issue Oct 9, 2024 · 5 comments

Comments

@ahalota
Copy link

ahalota commented Oct 9, 2024

I have a create-react-app application.
I tried to install this via yarn add shpjs
It downloaded the files, and dependencies correctly.
It seems something is wrong with the module resolution though, when I try to run my code it won't compile and gives this error (where "myfolder" is a valid location). I do have but-unzip in my node_modules folder, it came with this package's dependencies.

./node_modules/shpjs/lib/unzip.js Module not found: Can't resolve 'but-unzip' in '<myfolder>/node_modules/shpjs/lib'

Appreciate any ideas on how to resolve this. Thanks!

@calvinmetcalf
Copy link
Owner

so you've added import shp from 'shpjs'; to your app somewhere and when you run yard start it gives you that error?

@ahalota
Copy link
Author

ahalota commented Oct 9, 2024

Hm. I wish I could say more clearly what's happening when I run my site...I assume(?) create-react-app does some sort of magic which includes a compiling step, and it's at that step that I am getting this error.

Fails to compile because it can't find the module in <..>/node_modules/shpjs/lib, which is appropriate, since I don't have the library there, but instead in in <..>/node_modules/but-unzip/...

Which is my best guess was that something in @rollup/plugin-node-resolve wasn't acting the way I wanted

@calvinmetcalf
Copy link
Owner

the file dist/shp.esm.js is a compiled single file version of this library containing all it's dependencies appropriate to import into an app. You may just find it easier to copy that file into your code base so you can just do import shp from '../vendor/shp.esm.js' or something .

@ahalota
Copy link
Author

ahalota commented Oct 9, 2024

From some debugging my best theory right now is that the way we have create-react-app configured, it does not play nicely with dual-export libraries (which offer the esm/commonjs exports).

I'm going to do the direct import of the file and most likely try to get off of CRA for the future. If anyone has gotten this library to successfully load into a CRA project, please comment, thanks

@calvinmetcalf
Copy link
Owner

I've switched from create-react-app to vite and have found it to be an improvement, create-react-app is fine until you have to do anything that strays from it's garden path even a little, and then it falls apart.

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

2 participants