请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

webpack命令执行报错

老师你好 !我使用cnpm安装了需要的包后执行webpack命令编译时报错如下:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration.module has an unknown property 'loaders'. These properties are valid:

   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }

   -> Options affecting the normal modules (`NormalModuleFactory`).


我完全按照教程操作,里面有不一样的就是我在执行命令

cnpm install --save react react-dom babelify babel-preset-react

后有提示:

√ Installed 4 packages

√ Linked 31 latest versions

√ Run 0 scripts

peerDependencies WARNING babelify@* requires a peer of babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc but none was installed

Recently updated (since 2018-02-22): 1 packages (detail see file D:\reactD\mk\05-01\node_modules\.recently_updates.txt)

√ All packages installed (36 packages installed from npm registry, used 8s, speed 235.21kB/s, json 35(656.1kB), tarball 1.1MB)

所以我有执行了cnpm install --save babel-core

然后继续按照教程操作执行cnpm install --save babel-preset-es2015

有提示:

√ Installed 4 packages

√ Linked 31 latest versions

√ Run 0 scripts

peerDependencies WARNING babelify@* requires a peer of babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc but none was installed

Recently updated (since 2018-02-22): 1 packages (detail see file D:\reactD\mk\05-01\node_modules\.recently_updates.txt)

√ All packages installed (36 packages installed from npm registry, used 8s, speed 235.21kB/s, json 35(656.1kB), tarball 1.1MB)

但是我没有理会,

然后继续

执行webpack命令编译时首先遇到了提示:

The CLI moved into a separate package: webpack-cli.

Please install 'webpack-cli' in addition to webpack itself to use the CLI.

-> When using npm: npm install webpack-cli -D

-> When using yarn: yarn add webpack-cli -D

然后我执行了命令:cnpm install -g webpack-cli

完成后继续执行命令webpack

然后就看到了我现在所描述的这个报错,全部红色:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration.module has an unknown property 'loaders'. These properties are valid:

   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }

   -> Options affecting the normal modules (`NormalModuleFactory`).


正在回答

1回答

版本太高了,请参见 http://coding.imooc.com/learn/questiondetail/43877.html


=====================================================

此慕课网 React 课程学习遇到的常见问题以及没有审核通过的补充视频(如打包后的文件压缩、单独的 webpack 2 视频教程等)

我整理成了一个大的 QA 文档,可以直接参考我博客的整理。

基本包含了所有 React 初学时遇到的各种问题的解决方案。

我的博文地址:http://blog.parryqiu.com/2017/03/09/react-q-and-a/

 

目前文章主要包含了以下问题的解决方案:

一些课程资源,如源代码、思维导图、后台 API 源代码等;

关于 Webpack           2.0 详细使用的 20 集免费补充视频;

webpack-dev-server      不能自动刷新的问题;

使用 Webpack      2 搭建的 React 浏览器自动刷新的项目模板,多次测试可用;

React      Developer Tool 的问题;

缺少      react-html-attrs 插件;

babel-loader      没加载的错误;

fetch 的使用;

占用端口 8080 的问题;

错误 The      root route must render a single      element 的处理;

如何在chrome      console 中打开 paint flashing;

父组件通过 refs 获取子组件真实 DOM 节点的问题;

跳转 Route 的问题;

将      AntDesign 中的 getFieldProps 替换成      getFieldDecorator 的处理;

错误 Target      container is not a DOM element      的原因及解决方案;

慕课没有发布的更新课程;

React      Router 4.0 中 location undefined 的问题;

AntDesign      官方文档中的函数语法错误的解决方案;

解决课程中 React      Router 版本的差异问题;

课程中 API 的地址。


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信