Error: Cannot find module 'webpack'

李惟
  • 2.1k

运行

npm start

报错

Error: Cannot find module 'webpack'

安装了

npm install --save-dev webpack
cnpm install webpack-dev-server -g

解决不了问题,怎么办?

最后副一条我的package.json

{
  "name": "webpack",
  "version": "1.0.0",
  "description": "vue+webapck",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack-dev-server --inline"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer-loader": "^2.0.0",
    "babel": "^6.3.13",
    "babel-core": "^6.3.21",
    "babel-loader": "^6.2.0",
    "babel-plugin-transform-runtime": "^6.3.13",
    "babel-preset-es2015": "^6.3.13",
    "babel-runtime": "^5.8.34",
    "css-loader": "^0.16.0",
    "file-loader": "^0.8.5",
    "html-loader": "^0.3.0",
    "node-sass": "^3.4.2",
    "sass-loader": "^3.2.0",
    "style-loader": "^0.12.3",
    "url-loader": "^0.5.6",
    "vue-html-loader": "^1.2.0",
    "vue-loader": "^7.2.0",
    "webpack": "^1.15.0",
    "webpack-dev-server": "^1.14.0"
  },
  "keywords": [
    "vue",
    "webpack"
  ]
}
回复
阅读 10.4k
2 个回答

你要先安装webpack呀。先通过npm install --save-dev webpack 在项目中安装webpack,如果想实现热更新,再去安装webpack-dev-server。

非全局安装,这样执行

./node_modules/.bin/webpack
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏