網站首頁 編程語言 正文
react項目升級報錯,babel報錯,.babelrc配置兼容問題
由于開發環境和項目版本的兼容問題,嘗試升級了react-scripts后,一大堆問題接踵而至,翻遍了百度和csdn,往往解決了舊的又出現新的,或者開發沒問題而打包時報錯,現羅列一下遇到的主要問題和最終解決方案,以供參考。
遇到問題
digital envelope routines::unsupported
命令行運行 $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
? ? ? ? }
? ? ? ]
? ? ]
?},
必要時安裝依賴:“@babel/eslint-parser”
注:
babel-eslint 自 2020 年 3 月起已被棄用。 該軟件包已遷移到新的倉庫,如有需要請查閱 ‘@babel/eslint-parser’
react運行報錯TypeError
報錯:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string.
在同事幫忙下已解決,
現記錄一下思路
頁面 / 控制臺報錯
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)
……
根據提示,看出問題是在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
再運行時項目就跑起來了。
原文鏈接:https://blog.csdn.net/daoke_li/article/details/126120339
相關推薦
- 2022-09-30 Ajax實現關鍵字聯想和自動補全功能及遇到坑_AJAX相關
- 2022-04-07 python函數的重新定義及練習_python
- 2022-01-17 計算屬性 computed與 watch 的區別
- 2023-11-18 Python list寫入txt文件
- 2023-04-06 python?numpy.linalg.norm函數的使用及說明_python
- 2022-09-24 Golang?斷言與閉包使用解析_Golang
- 2022-10-04 python中xml格式的轉換方法_python
- 2023-04-06 OpenMP中For?Construct對dynamic的調度方式詳解_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支