react-router-dom@4.0.0 requires a peer of react@^15 but none is installed. You must install peer dependencies yourself

筅森魡賤 提交于 2020-03-21 11:56:30

问题


I have installed all required libraries using npm install and I also done npm install --save react-router-dom@4.0.0 but I am still getting this error.

My Package.json

  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "jquery": "^2.2.1",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "react-addons-test-utils": "^0.14.7",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "babel-preset-stage-1": "^6.1.18",
    "lodash": "^3.10.1",
    "react": "^15.6.2",
    "react-dom": "^0.14.3",
    "react-redux": "4.3.0",
    "react-router": "^2.0.1",
    "react-router-dom": "^4.0.0",
    "redux": "^3.0.4"
  }

After updating react, redux, react-redux,and all I got no warnings but got following error after I ran npm start

> node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 127.0.0.1:8080
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at net.js:1404:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! redux-simple-starter@1.0.0 start: `node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the redux-simple-starter@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myhome/.npm/_logs/2017-12-23T00_38_08_579Z-debug.log

回答1:


You need React in your package.json

Try the following in the folder where your package.json is placed:

npm install react --save

If react is already present in your package.json verify that the version is higher then 15.0.

If that's not fixing your error, please provide us your package.json




回答2:


With the help of @rieckpil, I have followed following steps and it fixed my problem.

1: On this page I collected latest version for all following libraries react, react-dom, react-redux, react-router, react-router-dom, redux and replaced it in my package.json file.

2: Run npm install

3: Run npm start. If getting errors like above, simply restart you computer and run npm start again.



来源:https://stackoverflow.com/questions/47948543/react-router-dom4-0-0-requires-a-peer-of-react15-but-none-is-installed-you-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!