What npm 'overrides' Actually Does When It Silences a Dependency Error
When npm install fails with an ERESOLVE error, developers commonly copy an 'overrides' snippet from GitHub into their package.json to resolve the conflict. The error typically occurs because a package like @testing-library/react-hooks declares a peer dependency on an older React version that does not match the project's installed version. The npm 'overrides' field works by rewriting the version number used during the dependency check, using the '$react' syntax to substitute the project's own installed React version. Critically, this does not verify whether the overridden package's internal code is actually compatible with the newer version — it only silences the version mismatch check. Developers should understand that using overrides bypasses npm's safeguard without confirming real runtime compatibility.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in