【Vue】webpack polyfilling 报错问题解决

1. 出现问题背景

在我编写完侧边栏组件后使用时,页面重新加载时报错
在这里插入图片描述

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添加

"browser": {

"path": false

}

在这里插入图片描述

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
当执行`vue init webpack`命令报错`Failed to download repo vuejs-templates/webpack: connect ETIMEDOUT`,这通常是由于无法连接到GitHub导致的连接超时错误。这个问题可能是由于一些公司屏蔽了GitHub所导致的。 解决这个问题的方法是可以尝试使用淘宝镜像来替代GitHub。可以按照以下步骤进行操作: 1. 首先,确保已经安装了`cnpm`,可以通过命令`npm install -g cnpm --registry=https://registry.npm.taobao.org`来进行安装。 2. 然后,使用`cnpm`来执行`vue init webpack`命令,即`cnpm init webpack`。 3. 等待安装完成后,就可以继续进行Vue项目的初始化工作了。 通过使用淘宝镜像,可以绕过对GitHub的依赖,从而避免连接超时的问题。这样就可以成功运行`vue init webpack`命令了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [vue init webpack project 超时报错解决方案](https://blog.csdn.net/JakeMa1024/article/details/108543246)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [vue初始化模板 vue init webpack命令下载的模板](https://download.csdn.net/download/qq_24297849/86514401)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yqyn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值