您的位置:首页技术文章
文章详情页

javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’

【字号: 日期:2023-09-21 09:08:38浏览:59作者:猪猪

问题描述

运行 cnpm start 运行'webpack-dev-server ' 后报错:没有找到webpack。packge.json文件内容如下:

{ '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:javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’

运行 :javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’报错:javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’

我全局安装的webpack 不知道为什么会报找不到webpack。但是自己手动输入 ’webpack-dev-server’运行成功:

javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’

希望知道是什么原因

问题解答

回答1:

试下npm run start

回答2:

webpack.config.js里使用了webpack,所以webpack也需局部安装(本项目)依赖;javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’javascript - npm start 运行’webpack-dev-server’报错 Cannot find module ’webpack’

标签: JavaScript
相关文章: