question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: Can't resolve 'poly-decomp'

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
liabrucommented, Mar 13, 2021

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 the decomp module as an argument (or set the global). I’m sure that will create just as much confusion as this error though.

1reaction
liabrucommented, Apr 11, 2021

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 use Common.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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found