项目更新,提交后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,最后得以解决问题。