Module not found: Can't resolve 'poly-decomp'
See original GitHub issueI am seeing this message in the debug output when using matter-js:
./node_modules/.pnpm/matter-js@0.16.1/node_modules/matter-js/build/matter.js Module not found: Can’t resolve ‘poly-decomp’ in ‘C:\dev\webpranks\node_modules.pnpm\matter-js@0.16.1\node_modules\matter-js\build’
This is the minimal code to reproduce:
import { Engine, Render, Bodies, World } from "matter-js";
const engine = Engine.create();
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top Results From Across the Web
poly-decomp - npm
poly-decomp.js. Library for decomposing a 2D polygon into convex pieces. Decomposing a convcave polygon into convex regions.
Read more >Can't resolve module (not found) in React.js - Stack Overflow
Console says that it can't find the module in the directory, but I've checked at least 10 times for typos. Anyways, here's the...
Read more >Can't resolve 'poly-decomp' in 'misskey/node_modules ... - Issuehunt
Summary. Module not found: Error: Can't resolve 'poly-decomp' in '/misskey/node_modules/matter-js/build' @ ./src/client/scripts/physics.ts 1:0-36 12:19-39 ...
Read more >poly-decomp.js
poly-decomp.js. Decomposition of 2D polygons into convex pieces in JavaScript. See the Github repo. Try drawing a polygon below! Settings. minEdgeLength.
Read more >How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To be clear for anyone still seeing this issue you can avoid the warning for the moment by just installing the module via
npm install poly-decomp --save
(even though it’s technically optional).The problem seems to be external - build tools don’t appear to handle conditional
require
calls as expected, which I’m not sure there’s a fix for (unless anybody has any ideas).So unfortunately there may need to be a breaking change coming (which I’ve been trying to avoid): removing this
require
all together and asking users to pass thedecomp
module as an argument (or set the global). I’m sure that will create just as much confusion as this error though.As of release
0.17.0
the approach is now to use the new function Common.setDecomp, which you can see in use on the concave example.The
window.decomp
global is also still supported, but it is still advised to specifically useCommon.setDecomp
where possible.There is no longer any
require
usage meaning bundlers should work fine, so considering the issue now resolved but feel free to comment still if needed. Thanks again for reporting.