React npm开始抛出错误

时间:2018-07-31 22:04:06

标签: node.js reactjs webpack-dev-server

我正在使用Node创建一个简单的HelloWorld应用程序并做出反应。我跑步时遵循了这个tutorial

  

npm开始

我收到以下错误:

> test1@1.0.0 start C:\Users\Saeed\Work\Test1
> webpack-dev-server

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:549
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Saeed\Work\Test1\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test1@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test1@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这是我的package.json:

{
  "name": "test1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
   "start": "webpack-dev-server",
   "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "webpack": "^4.16.3",
    "webpack-dev-server": "^3.1.5"
  }
}

有人可以指出我的错误吗?我npm install webpack-cli -D将解决问题。

0 个答案:

没有答案