npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: event-countdown-timer@1.0.0
npm error Found: react@17.0.2
npm error node_modules/react
npm error react@"17.0.2" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @wordpress/scripts@30.12.0
npm error node_modules/@wordpress/scripts
npm error dev @wordpress/scripts@"30.12.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /root/.npm/_logs/2025-03-07T17_37_58_563Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-03-07T17_37_58_563Z-debug-0.log
Assistant
The error you're encountering is related to dependency resolution in npm, specifically because the version of react you are using (17.0.2) is incompatible with the required version for @wordpress/scripts (^18.0.0). This is a common issue when different packages require different versions of the same dependency.
Here are a few ways to resolve this conflict:
Option 1: Upgrade React
The simplest and most straightforward solution is to upgrade your React version to satisfy the dependency requirement. You can update your react and react-dom in your package.json to version 18.0.0 or later:
Update package.json: Change the react and react-dom versions to at least 18.0.0.
json
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0",
// other dependencies...
}
Run the following command to install the updated dependencies:
bash
npm install
Option 2: Use Legacy Peer Dependencies
If you want to force the installation to proceed with the existing dependencies without upgrading React, you can use the --legacy-peer-deps flag:
bash
npm install --legacy-peer-deps
Option 3: Force Install
You can also forcefully install the dependencies with the --force flag, but be cautious as this may lead to broken dependencies:
bash
npm install --force
Option 4: Downgrade @wordpress/scripts
As an alternative, you could look for an older version of @wordpress/scripts that is compatible with React 17. However, if you choose this option, be cautious as you may miss out on updates or new features included in the latest version.
Check the version history of @wordpress/scripts and find a compatible version.
Change the version in your package.json accordingly.
Run npm install to apply the changes.
Option 5: Use Yarn
As an alternative, you can try using Yarn instead of npm. Yarn sometimes handles peer dependencies differently, which might resolve the issues for you.
If you don't have Yarn installed, you can install it globally:
bash
npm install -g yarn
Then, in your project directory, run:
bash
yarn install
Summary
The best course of action is to upgrade React to version 18.0.0 or higher if feasible for your project.
If upgrading is not an option, you can either use --legacy-peer-deps or --force to bypass the issue, though this should be a last resort.
Alternatively, check the version compatibility of @wordpress/scripts and install an appropriate version if necessary.