項目更新,提交后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,最后得以解決問題。