找不到模块' webpack-cli / bin / config-yargs' reactJS出错

时间:2018-06-08 05:05:32

标签: javascript reactjs

我正在尝试使用reactJS并完成教程。运行应用npm start后,我收到此错误。

错误:

E:\ReactUI\myReact>npm start

> reviewpedia@1.0.0 start E:\ReactUI\myReact
> webpack-dev-server --hot

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
module.js:540
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (E:\ReactUI\myReact\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reviewpedia@1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reviewpedia@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\Admin\AppData\Roaming\npm-cache\_logs\2018-06-08T04_54_55_281Z-debug.log

E:\ReactUI\myReact>

我从"webpack": "^4.10.2", "webpack-dev-server": "^3.1.4"更改了webpavk,但错误仍然相同。

这是我的package.json

{
  "name": "myApp",
  "version": "1.0.0",
  "description": "XYZ",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --hot"
  },
  "keywords": [
    "React",
    "App"
  ],
  "author": "XYZ",
  "license": "MIT",
  "dependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "webpack": "^2.1.0-beta.25",
    "webpack-dev-server": "^3.1.4"
  }
}

请帮我解决这个问题。

PS:我使用的是这个例子:Tutorial Points

安装npm install webpack-cli -D后,我收到以下错误。

E:\ReactUI\myReact\node_modules\webpack-cli\bin\convert-argv.js:156
                const webpackConfigurationValidationErrors = validateSchema(
                                                             ^

TypeError: validateSchema is not a function
    at processConfiguredOptions (E:\ReactUI\myReact\node_modules\webpack-cli\bin\convert-argv.js:156:48)
    at module.exports (E:\ReactUI\myReact\node_modules\webpack-cli\bin\convert-argv.js:150:10)
    at Object.<anonymous> (E:\ReactUI\myReact\node_modules\webpack-dev-server\bin\webpack-dev-server.js:234:54)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reviewpedia@1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reviewpedia@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\Admin\AppData\Roaming\npm-cache\_logs\2018-06-08T05_31_50_201Z-debug.log

E:\ReactUI\myReact>

0 个答案:

没有答案