Skip to content
Advertisement

i am just trying to install the package of react js but i am getting errors

I am just trying to install react but I am getting errors. I have installed npm -v 8.12.1 version in my system. I have tried to downgrade react but it doesn’t help

I have tried these type:

  1. update npm npm install npm -g
  2. downgraded react to "react": "15.3.0"
  3. cleared cache: npm cache clear
  4. removed node_modules, rm -rf node_modules,
  5. reinstalled node_modules, npm install
{
  "name": "ant-design-pro",
  "version": "2.0.0",
  "description": "An out-of-box UI solution for enterprise applications",
  "private": true,
  "scripts": {
    "precommit": "npm run lint-staged",
    "presite": "node ./scripts/generateMock.js && cd functions && npm install",
    "start": "cross-env APP_TYPE=site umi dev",
    "start:no-mock": "cross-env MOCK=none umi dev",
    "build": "umi build",
    "site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy",
    "analyze": "cross-env ANALYZE=1 umi build",
    "lint:style": "stylelint "src/**/*.less" --syntax less",
    "lint": "eslint --ext .js src mock tests && npm run lint:style",
    "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
    "lint-staged": "lint-staged",
    "lint-staged:js": "eslint --ext .js",
    "test": "umi test",
    "test:component": "umi test ./src/components",
    "test:all": "node ./tests/run-tests.js",
    "prettier": "prettier --write ./src/**/**/**/*",
    "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up",
    "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build",
    "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
    "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build"
  },
  "dependencies": {
    "@antv/data-set": "^0.9.6",
    "@babel/runtime": "^7.0.0",
    "antd": "^3.11.6",
    "bizcharts": "^3.2.2",
    "bizcharts-plugin-slider": "^2.0.3",
    "classnames": "^2.2.6",
    "dva": "^2.4.0",
    "enquire-js": "^0.2.1",
    "hash.js": "^1.1.5",
    "highlight.js": "^9.13.1",
    "lodash": "^4.17.10",
    "lodash-decorators": "^6.0.0",
    "marked": "^0.5.2",
    "memoize-one": "^4.0.0",
    "moment": "^2.22.2",
    "numeral": "^2.0.6",
    "nzh": "^1.0.3",
    "omit.js": "^1.0.0",
    "path-to-regexp": "^2.4.0",
    "prop-types": "^15.5.10",
    "qs": "^6.5.2",
    "rc-animate": "^2.4.4",
    "react": "^16.8.6",
    "react-container-query": "^0.11.0",
    "react-copy-to-clipboard": "^5.0.1",
    "react-document-title": "^2.0.3",
    "react-dom": "^16.8.6",
    "react-fittext": "^1.0.0",
    "react-router-dom": "^4.3.1",
    "save": "^2.3.2",
    "simplemde": "^1.11.2"
  },
  "devDependencies": {
    "@types/react": "^16.4.11",
    "@types/react-dom": "^16.0.6",
    "antd-pro-merge-less": "^0.0.9",
    "antd-pro-theme-webpack-plugin": "^1.1.8",
    "babel-eslint": "^9.0.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "cross-env": "^5.1.1",
    "cross-port-killer": "^1.0.1",
    "enzyme": "^3.4.4",
    "eslint": "^5.4.0",
    "eslint-config-airbnb": "^17.0.0",
    "eslint-config-prettier": "^3.0.1",
    "eslint-plugin-babel": "^5.1.0",
    "eslint-plugin-compat": "^2.5.1",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-markdown": "^1.0.0-beta.6",
    "eslint-plugin-react": "^7.11.1",
    "gh-pages": "^2.0.0",
    "husky": "^0.14.3",
    "lint-staged": "^7.2.0",
    "merge-umi-mock-data": "^0.0.3",
    "mockjs": "^1.0.1-beta3",
    "prettier": "1.14.2",
    "pro-download": "^1.0.1",
    "stylelint": "^9.4.0",
    "stylelint-config-prettier": "^4.0.0",
    "stylelint-config-standard": "^18.0.0",
    "umi": "^2.1.1",
    "umi-plugin-ga": "^1.0.3",
    "umi-plugin-react": "^1.1.1"
  },
  "optionalDependencies": {
    "puppeteer": "^1.6.0"
  },
  "lint-staged": {
    "**/*.{js,jsx,less}": [
      "prettier --write",
      "git add"
    ],
    "**/*.{js,jsx}": "npm run lint-staged:js",
    "**/*.less": "stylelint --syntax less"
  },
  "engines": {
    "node": ">=8.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 10"
  ]
}

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-fittext@1.0.0
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   react@"^16.8.6" from the root project
npm ERR!   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from @ant-design/create-react-context@0.2.5
npm ERR!   node_modules/@ant-design/create-react-context
npm ERR!     @ant-design/create-react-context@"^0.2.4" from antd@3.26.20
npm ERR!     node_modules/antd
npm ERR!       antd@"^3.11.6" from the root project
npm ERR!       1 more (umi-plugin-react)
npm ERR!     @ant-design/create-react-context@"^0.2.4" from rc-mentions@0.4.2
npm ERR!     node_modules/rc-mentions
npm ERR!       rc-mentions@"~0.4.0" from antd@3.26.20
npm ERR!       node_modules/antd
npm ERR!         antd@"^3.11.6" from the root project
npm ERR!         1 more (umi-plugin-react)
npm ERR!     2 more (rc-tabs, rc-tree)
npm ERR!   47 more (@ant-design/icons-react, airbnb-prop-types, antd, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.0.0" from react-fittext@1.0.0
npm ERR! node_modules/react-fittext
npm ERR!   react-fittext@"^1.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@15.7.0
npm ERR! node_modules/react
npm ERR!   peer react@"^15.0.0" from react-fittext@1.0.0
npm ERR!   node_modules/react-fittext
npm ERR!     react-fittext@"^1.0.0" 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 C:Users91639AppDataLocalnpm-cacheeresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:Users91639AppDataLocalnpm-cache_logs2022-06-03T09_27_25_556Z-debug-0.log

Advertisement

Answer

As the error reads, you have dependency conflict. Run the command with –legacy-peer-deps.

npm install --legacy-peer-deps
Advertisement