react 打包報 createRequire is not a function Referenced from: BaseConfig


項目更新,提交后Jenkins部署報以下錯誤:

Creating an optimized production build...
Failed to compile.

createRequire is not a function
Referenced from: BaseConfig


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lcloud_webview@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the lcloud_webview@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

刪除node_modules和整個工作區間都試了一次,還是報錯。在本地一切正常。

搜索后發現:BaseConfig is a variable of the create-react-app react-scripts module in node_modules/react-scripts/config/webpack.config.js

之前因為其它原因升級過react-scripts和react包,而react-scripts 4.x需要更高點的node版本支持,

我在Jenkins上試着升級node和npm提示沒有權限,沒辦法只能把react-scripts降到3.x,react降到16.x,最后得以解決問題。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM