最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 but none was installed

npm crifan 3852浏览 0评论

折腾:

【已解决】ReactJS中Webpack打包时分离css

期间,在npm安装别的库时看到警告:

➜  react-hot-boilerplate git:(master) ✗ npm install –save-dev postcss-loader
npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN react-dom@15.6.1 requires a peer of react@^15.6.1 but none was installed.
updated 1 package in 9.851s

感觉是:

此处之前已升级到了Webpack 3了:

【已解决】把ReactJS项目react-hot-boilerplate中的Webpack 1升级到Webpack 3

所以此处才出现警告:

babel-loader@6.2.10的版本,只是针对于webpack的1或2的,

应该需要升级了。

另外,是不是这也就是,之前把require换成import但是失败的原因?

 此处当前版本是:

  “devDependencies”: {
    “babel-core”: “^6.0.20”,
    “babel-eslint”: “^4.1.3”,
    “babel-loader”: “^6.0.1”,
    “babel-preset-es2015”: “^6.0.15”,
    “babel-preset-react”: “^6.0.15”,
    “babel-preset-stage-0”: “^6.0.15”,
。。。
    “webpack”: “^3.5.4”,
    “webpack-dev-server”: “^2.7.1”
  },

意思很清楚:

babel-loader”: “^6.0.1

和:

    “webpack”: “^3.5.4”

不兼容,需要去升级babel-loader

npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 but none was installed

Unmet peer dependency webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc · Issue #2685 · almende/vis

学习ReactNative笔记三 __React基础 – 简书

» ReactNative快速教程3/9 React 基础(14) 笔记 – GO八婆网 [教育视频]-YOUTUBE教育-GO八婆网

别处是重新安装:

sudo npm i babel-runtime@6 –save-dev

即可。

reactjs – UNMET PEER DEPENDENCY webpack@2.2.0-rc.3 – Stack Overflow

UNMET PEER DEPENDENCY webpack#2.2.0-rc.3 – reactjs

babel-loader

babel/babel-loader: Webpack plugin for Babel

果然是我猜的:

“webpack 1.x | babel-loader <= 6.x

webpack 2.x | babel-loader >= 7.x (recommended) (^6.2.10 will also work, but with deprecation warnings)

webpack 3.x | babel-loader >= 7.1”

然后去升级:

➜  react-hot-boilerplate git:(master) ✗ npm install –save-dev babel-loader babel-core babel-preset-env
npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN react-dom@15.6.1 requires a peer of react@^15.6.1 but none was installed.
added 3 packages and updated 2 packages in 14.175s

结果还是没有升级到7版本:

  “devDependencies”: {
    “babel-core”: “^6.25.0”,
    “babel-eslint”: “^4.1.3”,
    “babel-loader”: “^6.4.1”,
    “babel-preset-env”: “^1.6.0”,
    “babel-preset-es2015”: “^6.0.15”,
    “babel-preset-react”: “^6.0.15”,
    “babel-preset-stage-0”: “^6.0.15”,

算了,删除掉所有的babel,然后重新安装最新版本的吧:

➜  react-hot-boilerplate git:(master) ✗ npm uninstall babel-core babel-eslint babel-loader babel-preset-env babel-preset-es2015 babel-preset-react babel-preset-stage-0
npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN react-dom@15.6.1 requires a peer of react@^15.6.1 but none was installed.
removed 118 packages in 14.07s

babel-loader配置 | 三寸稚笔

https://robin-front.github.io/2016/04/08/babel-loader配置/

babel-loader · webpack 中文文档(2.2)

babel-loader

Using ES6 and ES7 in the Browser, with Babel 6 and Webpack

参考官网去重新安装babel:

但是需要先搞清楚:

【基本解决】babel-loader中preset的各个参数es2015 react stage-0 env的含义

先去试试再说:

npm install

babel-eslint:以后需要了再安装

目前需要安装的:

babel-preset-env

babel-preset-react

babel-preset-stage-0

.babelrc中的配置:

      “env”,

      “react”,

      “stage-0”

webpack 相关知识 · Issue #31 · wy-ei/notebook

babel-core

babel-loader

babel-runtime

babel-plugin-transform-runtime

babel-polyfill

npm install –save-dev babel-core babel-loader babel-preset-env webpack babel-preset-react babel-preset-stage-0 babel-runtime babel-plugin-transform-runtime babel-polyfill babel-eslint

➜  react-hot-boilerplate git:(master) ✗ npm install –save-dev babel-core babel-loader babel-preset-env webpack babel-preset-react babel-preset-stage-0 babel-runtime babel-plugin-transform-runtime babel-polyfill babel-eslint
npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN react-dom@15.6.1 requires a peer of react@^15.6.1 but none was installed.
added 51 packages, updated 3 packages and moved 9 packages in 22.5s

安装后的版本:

  “devDependencies”: {
    “babel-core”: “^6.25.0”,
    “babel-eslint”: “^7.2.3”,
    “babel-loader”: “^7.1.1”,
    “babel-plugin-transform-runtime”: “^6.23.0”,
    “babel-polyfill”: “^6.23.0”,
    “babel-preset-env”: “^1.6.0”,
    “babel-preset-react”: “^6.24.1”,
    “babel-preset-stage-0”: “^6.24.1”,
    “babel-runtime”: “^6.25.0”,
    “copy-webpack-plugin”: “^4.0.1”,
    “eslint”: “^1.10.3”,
    “eslint-plugin-react”: “^3.6.2”,
    “express”: “^4.13.4”,
    “extract-text-webpack-plugin”: “^3.0.0”,
    “less”: “^2.7.2”,
    “less-loader”: “^4.0.5”,
    “postcss-loader”: “^2.0.6”,
    “url-loader”: “^0.5.9”,
    “webpack”: “^3.5.4”,
    “webpack-dev-server”: “^2.7.1”

然后去配置。

gaearon/react-hot-loader: Tweak React components in real time.

react-hot-loader/docs at master · gaearon/react-hot-loader

【总结】

此处删除了之前的babel的所有的库,重新安装了所有的库:

npm install –save-dev babel-core babel-loader babel-preset-env webpack babel-preset-react babel-preset-stage-0 babel-runtime babel-plugin-transform-runtime babel-polyfill babel-eslint

然后就解决了这个警告了。

转载请注明:在路上 » 【已解决】npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 but none was installed

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
66 queries in 0.244 seconds, using 18.86MB memory