search

Home  >  Q&A  >  body text

javascript - npm start runs 'webpack-dev-server' and reports an error Cannot find module 'webpack'

Run cnpm start and run "webpack-dev-server". After running "webpack-dev-server", an error is reported: webpack is not found.
The contents of the packge.json file are as follows:

{
      "name": "test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "webpack-dev-server "
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "webpack-dev-server": "^2.4.5"
      }
  }

webpack.config.js:

Run:
Error:

I installed webpack globally. I don’t know why it reports that webpack cannot be found.
But manually enter 'webpack-dev-server'
Run successfully:

Hope to know the reason

淡淡烟草味淡淡烟草味2827 days ago821

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:33:41

    Try itnpm run start

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:33:41

    webpack.config.js里使用了webpack,所以webpackYou also need to partially install (this project) dependencies;

    reply
    0
  • Cancelreply