在内存有限且没有交换空间的机器上, npm run build
可能会失败,这在云环境中很常见。 即使使用小项目,此命令也可以将系统中的 RAM 使用量增加数百兆字节,因此如果可用内存少于 1 GB,则构建可能会失败,并显示以下消息:
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.
如果你完全确定没有终止该过程,请考虑向你正在构建的计算机 增加一些交换空间,或在本地构建项目。