Dodi’s booking app engine: write package.json (React, react-query, use-sync-external-store, a calendar with react as a peer or a dependency) and run npm…
Why it matters
ERESOLVE unable to resolve dependency tree and Invalid hook call are the two errors most met when upgrading React. Both are about peers: in the first npm refuses a range that does not fit, in the second a plugin brings its own React. Knowing the difference makes you fix ranges rather than patch with --force.
The key idea
A peer means "use yours": one React for everyone, and npm checks it
Common mistakes
Invalid hook call though the component code is right There are almost always two Reacts in node_modules: the hook is called from a copy the renderer never set up. Check npm ls react. A plugin that writes react in dependencies should move it to peerDependencies; meanwhile align the range, or force one copy with overrides.
npm 7 and later install peers automatically, then ERESOLVE npm now checks peer ranges against the app’s React. Read the plugin’s name on the Could not resolve dependency line, then upgrade that plugin to a version that accepts your React. --legacy-peer-deps and --force only get the install through; npm ls still marks the tree invalid.
Putting react in a plugin’s dependencies "to be safe", then an error While its range fits the app’s React, npm uses one copy and all looks safe. Once the app moves up, the plugin gets its own nested React: two Reacts, broken hooks. Write React in peerDependencies (and in devDependencies for developing the plugin).
Try it in this playground
Let npm install React With no react in package.json, see which version npm picks.
Meet ERESOLVE React ^19.2.0 with use-sync-external-store 1.2.0.
See npm ls mark invalid Install with --legacy-peer-deps or --force while a range does not fit.
Two Reacts, one app kalender-bengkel with react in dependencies, the app on React 19.