react-router-dom@4.0.0 需要 react@^15 的对等体,但已安装 none。您必须自己安装对等依赖项
react-router-dom@4.0.0 requires a peer of react@^15 but none is installed. You must install peer dependencies yourself
我已经使用 npm install
安装了所有必需的库,我也安装了 npm install --save react-router-dom@4.0.0
,但我仍然收到此错误。
我的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"
}
在更新 react、redux、react-redux 之后,我没有收到任何警告,但在 运行 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
您的 package.json
需要 React
在 package.json
所在的文件夹中尝试以下操作:
npm install react --save
如果 react
已经存在于您的 package.json
中,请确认版本高于 15.0。
如果这不能解决您的错误,请向我们提供您的 package.json
在@rieckpil 的帮助下,我按照以下步骤解决了我的问题。
1:在这个 page 上,我收集了以下所有库的最新版本 react、react-dom、react-redux、react-router、react-router-dom、 redux 并将其替换为我的 package.json
文件。
2: 运行 npm install
3: 运行 npm start
。如果出现上述错误,只需重新启动计算机并再次 运行 npm start
。
我已经使用 npm install
安装了所有必需的库,我也安装了 npm install --save react-router-dom@4.0.0
,但我仍然收到此错误。
我的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"
}
在更新 react、redux、react-redux 之后,我没有收到任何警告,但在 运行 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
您的 package.json
在 package.json
所在的文件夹中尝试以下操作:
npm install react --save
如果 react
已经存在于您的 package.json
中,请确认版本高于 15.0。
如果这不能解决您的错误,请向我们提供您的 package.json
在@rieckpil 的帮助下,我按照以下步骤解决了我的问题。
1:在这个 page 上,我收集了以下所有库的最新版本 react、react-dom、react-redux、react-router、react-router-dom、 redux 并将其替换为我的 package.json
文件。
2: 运行 npm install
3: 运行 npm start
。如果出现上述错误,只需重新启动计算机并再次 运行 npm start
。