npm error peer invalid webpack-dev-server@2.10.0想要webpack@^2.2.0 ||

时间:2018-01-09 12:37:54

标签: node.js reactjs npm webpack npm-install

我通过下面的npm安装了依赖项是package.json

{
  "name": "springbootreactjs2",
  "version": "1.0.0",
  "description": "Spring boot with reactjs",
  "scripts": {
    "watch": "webpack --watch -d"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.17.1",
    "react": "16.0.0",
    "react-dom": "^16.2.0",
    "react-router-dom": "^4.2.2",
    "rest": "^2.0.0",
    "webpack": "^2.2.0"
  },
  "devDependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "7.1",
    "babel-polyfill": "^6.16.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0"
  }
}

每当我想安装一个依赖项时,它就会抛出以下错误

npm WARN package.json springbootreactjs2@1.0.0 No repository field.
npm WARN package.json springbootreactjs2@1.0.0 No README data
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "react@16.0.0" "--save"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package webpack@3.10.0 does not satisfy its siblings' p
eerDependencies requirements!
npm ERR! peerinvalid Peer babel-loader@6.4.1 wants webpack@1 || 2 || ^2.1.0-beta
 || ^2.2.0-rc
npm ERR! peerinvalid Peer webpack-dev-server@2.10.0 wants webpack@^2.2.0 || ^3.0
.0

npm ERR! Please include the following file with any support request:

以下是我正在运行的安装命令

npm install --save reactstrap@next react react-dom

最初webpack版本是3.10.0我手动修改了webpack版本到2.2.0但仍然出于某些原因仍在选择版本3.10.0。

不确定这里有什么问题

1 个答案:

答案 0 :(得分:0)

  1. 从您的package.json文件中删除您尚未在本地安装的所有依赖项,然后重试
  2. 使用npm install -g npm@latest更新您的npm。 使用npm install <dependency_name>安装缺少的依赖项,然后再次运行命令。

如果这不起作用,请继续阅读:

我面临着同样的问题。尽管我可以使用npm安装webpack,但无法安装webpack-cli。所以我:

  1. 1)将npm版本更新为最新版本。
  2. 已安装的纱线(使用百胜 或apt-get等)。
  3. 安装了所有依赖项(包括 webpack-cli)使用yarn

这解决了我的问题。