webpack版本问题 Cannot read property ‘createHash‘ of undefined

简介: webpack版本问题 Cannot read property ‘createHash‘ of undefined

webpack版本问题:

cnpm install 时有警告:requires a peer of webpack@^3.1.0 but webpack@4.41.2 was installed,可以看出webpack版本有問題,就是我項目要求使用webpack@^4.1.0但下载的是webpack@5.41.2

主要原因:先执行npm install 会下载最新版本的webpack

第一步:删除node_moudls依赖

安装 rimraf

可以全局安装,每个项目都可以使用

npm install rimraf -g //安装rimraf

在项目里面打开命令行工具

rimraf node_modules //删除文件

第二步:

先执行cnpm install webpack@^4.1.0安装webpack,再执行cnpm install,之后再运行npm run serve不报错了

第二个问题:

版本错误 npm run build时报错 webpack 是4.46.0的版本 安装的确实4.1.0就会报错

相关文章
|
11月前
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
11月前
|
JavaScript 测试技术
在不同 webpack 版本的 Vue 项目中配置 Storybook
在不同 webpack 版本的 Vue 项目中配置 Storybook
|
11月前
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
171 0
|
11月前
|
JavaScript
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
217 0
|
11月前
|
前端开发 JavaScript
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
252 0
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
|
9月前
|
缓存 前端开发 JavaScript
Webpack 打包的基本原理
【10月更文挑战第5天】
|
9月前
|
前端开发 JavaScript
ES6模块化和webpack打包
【10月更文挑战第5天】
|
10月前
|
JavaScript
webpack打包TS
webpack打包TS
188 60