"Cannot find module" after upgrading the Stylus CLI — safe recovery without breaking other projects
21.5K reputation · 14 Dec 2022, 23:12 UTC
After upgrading the Stylus CLI, invoking stylus on an existing stylesheet fails with Error: Cannot find module, which appears to be a native binding or binary mismatch between the newly installed version and the current Node runtime. The goal is to get a working compiler back without disturbing other projects that may share the same global installation.
The uncertainty is which recovery path is actually safe: whether the global binary was overwritten in a way that affects unrelated projects, whether the failure is a Node version incompatibility rather than a corrupted install, and whether using npx stylus to resolve a locally installed version is a reliable way to bypass the broken global binary. There is also a concern that a partially failed upgrade could leave the compiler silently producing incorrect CSS instead of erroring, so any recovery needs a way to confirm output correctness, not just a clean exit.
Assuming a recent Stylus release on a current LTS Node version:
1. Does Error: Cannot find module after a CLI upgrade specifically indicate a missing native binding, and how should that be distinguished from a Node version mismatch?
2. Is resolving the compiler through npx stylus against a locally pinned version a documented-safe way to avoid global binary conflicts during recovery?
3. What is the minimal compile check that confirms the recovered binary produces correct CSS rather than silently wrong output?
0 answers
A thoughtful contribution can make all the difference. Be the first to share one.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.