【Vue】webpack polyfilling 报错

1. 出现问题描述

npm run serve 项目时报错

ERROR Failed to compile with 1 error 10:33:22 ├F10: AM┤

error in ./src/router/routes.js

Module not found: Error: Can't resolve 'path' in '/Users/guolijun/Desktop/vue-oil-enterprise/src/router'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.

This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'

  • install 'path-browserify'

If you don't want to include a polyfill, you can use an empty module like this:

resolve.fallback: { "path": false }

2. 解决方案

搜索到解决方案: https://www.reddit.com/r/react/comments/w7yddk/how_do_i_fix_this_error_with_webpack_polyfilling/
package.json添加

javascript 复制代码
"browser": {

"path": false

}
相关推荐
JarvanMo12 分钟前
借助FlutterFire CLI实现Flutter与Firebase的多环境配置
前端·flutter
苹果酱056713 分钟前
python3语言基础语法整理
java·vue.js·spring boot·mysql·课程设计
Jedi Hongbin26 分钟前
echarts自定义图表--仪表盘
前端·javascript·echarts
凯哥197030 分钟前
Sciter.js指南 - 桌面GUI开发时使用第三方模块
前端
边洛洛31 分钟前
对Electron打包的exe文件进行反解析
前端·javascript·electron
财神爷亲闺女31 分钟前
js 实现pc端鼠标横向拖动滚动
前端
用户20311966009631 分钟前
sheet在SwiftUI中的基本用法
前端
晴殇i32 分钟前
一行代码搞定防抖节流:JavaScript新特性解析
前端·javascript