'npm cannot resolve react depencency

All the code is available in https://github.com/Andful/netlify-cms-widget-create-select/tree/move-to-esbuild.
I have the following package.json

{
  "name": "netlify-cms-widget-create-select",
  "description": "A simple create select widget for netlify-cms which allows creating entries. The create select widget's entries are up to date to the last website build. The create select can be populated by plain text file, json file, RSS feed or HTML page.",
  "keywords": [
    "netlify",
    "netlify-cms",
    "netlify-cms-widget",
    "netlify-cms-widget-create-select",
    "cms",
    "widget",
    "starter",
    "boilerplate"
  ],
  "version": "1.2.0",
  "homepage": "https://github.com/Andful/netlify-cms-widget-create-select",
  "license": "MIT",
  "module": "dist/index.js",
  "main": "src/index.ts",
  "devDependencies": {
    "@types/react-select": "^5.0.1",
    "@typescript-eslint/eslint-plugin": "^5.18.0",
    "@typescript-eslint/parser": "^5.0.0",
    "esbuild": "^0.14.34",
    "esbuild-plugin-alias": "^0.2.1",
    "eslint": "^8.12.0",
    "immutable": "^3.7.6",
    "netlify-cms-lib-widgets": "^1.8.0",
    "netlify-cms-ui-default": "^2.15.5",
    "prop-types": "^15.6.1",
    "react-immutable-proptypes": "^2.1.0",
    "typescript": "^4.2.4"
  },
  "peerDependencies": {
    "react": "^16.8.0"
  },
  "scripts": {
    "build": "tsc",
    "prepublishOnly": "npm run build",
    "test": "echo 0"
  },
  "dependencies": {
    "eslint-plugin-react": "^7.29.4",
    "netlify-cms": "^2.10.190",
    "path-browserify": "^1.0.1",
    "react-select": "^5.2.2"
  }
}

When i run npm install I get the following error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0" from the root project
npm ERR!   peer react@"^16.8.0 || ^17.0.0" from [email protected]
npm ERR!   node_modules/react-select
npm ERR!     react-select@"^5.2.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from [email protected]
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@"^16.8.0 || ^17.0.0" from [email protected]
npm ERR!   node_modules/react-select
npm ERR!     react-select@"^5.2.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/andful/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/andful/.npm/_logs/2022-04-08T17_04_15_674Z-debug-0.log

Why does npm not just install [email protected] as it is compatible with react-select@"^5.2.2"?

I tried both npm install --force and npm install --legacy-peer-deps but in the directory develop I try running the built code but an invalid hook call error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source