這篇“react項目升級報錯,babel報錯,babelrc配置兼容等問題如何解決”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內容,內容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“react項目升級報錯,babel報錯,babelrc配置兼容等問題如何解決”文章吧。
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’
報錯: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
再運行時項目就跑起來了。
以上就是關于“react項目升級報錯,babel報錯,babelrc配置兼容等問題如何解決”這篇文章的內容,相信大家都有了一定的了解,希望小編分享的內容對大家有幫助,若想了解更多相關的知識內容,請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。