简体   繁体   English

npm启动不运行react项目

[英]npm start not run react project

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 ). npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! newreact@1.0.0 start: webpack npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the newreact@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! C:\\Users\\Designer\\AppData\\Roaming\\npm-cache_logs\\2018-05-16T08_09_23_588Z-debug.log

You really need to tell us the version of webpack you are using and post your webpack.config.js file, but I'll try and help. 您确实需要告诉我们您所使用的Webpack的版本,并发布您的webpack.config.js文件,但我会尽力帮助您。 I'm assuming webpack 4. 我假设是webpack 4。

This bit of the log says there is something wrong with how you have written your webpack.config.js file. 这段日志表明您编写webpack.config.js文件的方式有问题。

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

This line further describes the problem. 此行进一步描述了问题。

configuration.module has an unknown property 'loaders'.

Then it goes on to tell you what properties are valid, and you'll see loaders is not listed. 然后继续告诉您哪些属性有效,并且您会看到未列出加载程序。 In webpack 4 you need to use 'rules', not 'loaders'. 在webpack 4中,您需要使用“规则”,而不是“加载程序”。

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

Your modules object should look something like the following, so perhaps take a look at this page and compare the modules object to your own. 您的模块对象应类似于以下内容,因此也许请看一下此页面并将模块对象与您自己的模块对象进行比较。

module: {
  rules: [
    {
      test: /\.css$/,
      use: [
        { loader: 'style-loader' },
        {
          loader: 'css-loader',
          options: {
            modules: true
          }
        }
      ]
    }
  ]
}

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM