macOS Big Sur 更新后,Docker 容器中的 React 构建失败

时间:2021-05-12 08:33:34

标签: reactjs docker build containers macos-big-sur

更新到 macOS Big Sur 后,我无法在 Docker 容器内构建 React。

 => ERROR [base_build 9/9] RUN npm run build                                                                                                                                    94.4s 
------                                                                                                                                                                                
 > [base_build 9/9] RUN npm run build:                                                                                                                                                
#23 1.110 
#23 1.110 > mp-app@0.1.0 build /app
#23 1.110 > react-scripts build
#23 1.110 
#23 4.913 Creating an optimized production build...
#23 93.67 The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.
#23 93.98 npm ERR! code ELIFECYCLE
#23 93.98 npm ERR! errno 1
#23 94.01 npm ERR! mp-app@0.1.0 build: `react-scripts build`
#23 94.01 npm ERR! Exit status 1
#23 94.01 npm ERR! 
#23 94.01 npm ERR! Failed at the mp-app@0.1.0 build script.
#23 94.01 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
#23 94.18 
#23 94.18 npm ERR! A complete log of this run can be found in:
#23 94.19 npm ERR!     /root/.npm/_logs/2021-05-12T07_02_11_162Z-debug.log
------
executor failed running [/bin/sh -c npm run build]: exit code: 1

1 个答案:

答案 0 :(得分:0)

解决问题的是将项目从 Spotlight 索引工具中排除。似乎这个使用了大量资源并且导致构建失败。转到 System preferences,然后搜索 Spotlight。然后转到 Privacy 选项卡并添加包含您的项目的目录。我不必重新启动笔记本电脑,但这也可能是必要的。它降低了笔记本电脑的温度并略微提高了速度。