老师你好 !我使用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`).
轻松入门 React 开发,React Router 4 与 Webpack 2 完美升级项目
了解课程