網(wǎng)站首頁 編程語言 正文
react項(xiàng)目升級報(bào)錯,babel報(bào)錯,.babelrc配置兼容等問題及解決_React
作者:daoke_li ? 更新時(shí)間: 2022-10-03 編程語言react項(xiàng)目升級報(bào)錯,babel報(bào)錯,.babelrc配置兼容問題
由于開發(fā)環(huán)境和項(xiàng)目版本的兼容問題,嘗試升級了react-scripts后,一大堆問題接踵而至,翻遍了百度和csdn,往往解決了舊的又出現(xiàn)新的,或者開發(fā)沒問題而打包時(shí)報(bào)錯,現(xiàn)羅列一下遇到的主要問題和最終解決方案,以供參考。
遇到問題
digital envelope routines::unsupported
命令行運(yùn)行 $env:NODE_OPTIONS=“–openssl-legacy-provider” ,再次啟動即可
Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): “decorators-legacy”, “decorators”.
require() of ES Module ……is not supported.
Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): “decorators-legacy”, “decorators”.
[eslint] The “path” argument must be of type string. Received an instance of Array
[eslint] ESLint configuration in .eslintrc is invalid:
- Unexpected top-level property “babel”.
最終解決方案
刪掉根目錄下的.babelrc文件,在package.json中配置:
?"babel": {
? ? "presets": [
? ? ? "react-app"
? ? ],
? ? "plugins": [
? ? ? [
? ? ? ? "@babel/plugin-proposal-decorators",
? ? ? ? {
? ? ? ? ? "legacy": true
? ? ? ? }
? ? ? ]
? ? ]
?},
必要時(shí)安裝依賴:“@babel/eslint-parser”
注:
babel-eslint 自 2020 年 3 月起已被棄用。 該軟件包已遷移到新的倉庫,如有需要請查閱 ‘@babel/eslint-parser’
react運(yùn)行報(bào)錯TypeError
報(bào)錯:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string.
在同事幫忙下已解決,
現(xiàn)記錄一下思路
頁面 / 控制臺報(bào)錯
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
? ?at validateString (internal/validators.js:117:11)
? ?at Object.join (path.js:375:7)
? ?at noopServiceWorkerMiddleware (D:\git\healthyWashing\node_modules\react-dev-utils\noopServiceWorkerMiddleware.js:14:26)
……
根據(jù)提示,看出問題是在react-dev-utils下面的noopServiceWorkerMiddleware里,
全局搜索‘"react-dev-utils"’,注意有雙引號,找到node_modules/react-scripts/package.json文件中的"react-dev-utils": "^10.0.0",這一行。
考慮到可能是沒有鎖定版本,最近有包有更新后造成bug的可能,所以去掉尖角號^,
然后 清除緩存并重新安裝依賴
npm cache clean --force
npm install
再運(yùn)行時(shí)項(xiàng)目就跑起來了。
原文鏈接:https://blog.csdn.net/daoke_li/article/details/126120339
相關(guān)推薦
- 2023-10-14 uni-app adb安卓wifi無線調(diào)試
- 2022-01-12 對比原生Node封裝的Express路由 和 express框架路由
- 2022-04-17 前端傳數(shù)組,后端怎么接收的問題
- 2022-07-19 Linux手工配置靜態(tài)ip地址
- 2022-01-19 正則表達(dá)式匹配日期格式y(tǒng)yyy-mm-dd(支持閏年)
- 2022-07-22 在windows上配置git支持多賬號
- 2022-11-05 Nginx監(jiān)控模塊(vts模塊)詳解_nginx
- 2022-12-03 pytorch模型保存與加載中的一些問題實(shí)戰(zhàn)記錄_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支