在安装reactJS时遇到问题

时间:2018-07-16 19:16:55

标签: node.js reactjs npm

我无法使用以下指南安装reactJS: https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm

我正在使用: npm 4.2.0 节点7.10.0 红帽企业Linux服务器版本7.2(Maipo)

这是我得到的错误:

[root@webdev2 reactJSApp]# npm start

> test@1.0.0 start /opt/swtapps/reactJSApp
> webpack-dev-server --hot

✖ 「wds」: 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! Linux 3.10.0-327.10.1.el7.x86_64
npm ERR! argv "/usr/local/node/bin/node" "/usr/local/node/bin/npm" "start"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 start script 'webpack-dev-server --hot'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls test
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/.npm/_logs/2018-07-16T19_07_33_854Z-debug.log

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

该教程已过时。 Webpack 4中的加载程序定义为:

module: {
  rules: [
    {
      test: /\.jsx?$/,
      // options for the loader
    },
  ],
}

对于此类问题,我建议阅读documentation of webpack