我们使用角度10.2,电子4.2,电子生成器22.9和节点10.16.0。此外,我们还有一个jenkins管道,每次发出Pull请求时都要执行。此管道创建一个AWS windows实例(t2.large),以便下载代码并构建.exe文件。问题是在编译代码时,会弹出以下错误:Fatal error # API fatal error handler returned after process out of memory on the background thread.
节点变量--max_old_space_size value is 4191.868721008301 MB。如果手动启动AWS windows实例,运行npm install并手动构建代码,则不会触发任何错误,构建完全成功。该错误仅在jenkins启动AWS windows实例时发生。
在安装了--max_old_space_size=1.5GB的mac环境中,构建过程完全成功。同样,当使用--max_old_space_size=1.5GB在windows中手动测试时,构建也可以很好地完成。如果变量设置为--max_old_space_size=512MB,构建将失败,并显示另一个错误Javascript heap out of memory。
我猜是不是跟jenkins线程内存有关?但是我还没有找到增加线程内存的方法。
任何想法,小贴士都会很有帮助。
Jenkins文件:
stage ('Build Windows app') {
node('windows-electron') {
// Wipe the workspace so we are building completely clean
deleteDir()
checkout scm
bat """
cd app
call npm run node-memory
call node -v
call npm --no-git-tag-version version \"${version}\"
call npm install
REM call npm run test - tests disabled on Windows for now (they run on Mac OS)
call npm run build"""
}
}Package.json构建脚本:"build": "npm run download-translations && ng build --prod && electron-webpack && electron-builder --publish=never",
发布于 2020-11-19 18:19:33
由于这个问题从angular 9 and 10 as well开始,我们创建了一个linux从站来执行构建过程,然后在mac和windows从站中隐藏文件和解锁。
node('nvm-slave') {
// Wipe the workspace so we are building completely clean
deleteDir()
checkout scm
nvm(nvmInstallURL: 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh', nvmIoJsOrgMirror: 'https://iojs.org/dist', nvmNodeJsOrgMirror: 'https://nodejs.org/dist', version: '10.16.0') {
sh '''cd app
npm install
npx ng build --prod
'''
}
stash name: "folder-to-stash", includes: "path/to/folder/to/stash/**"
}
stage ('Build Windows app') {
node('windows-electron') {
// Wipe the workspace so we are building completely clean
deleteDir()
checkout scm
unstash "folder-to-stash"
bat """
cd app
call node -v
call npm --no-git-tag-version version \"${version}\"
call npm install
REM call npm run test - tests disabled on Windows for now (they run on Mac OS)
call npm run postbuild"""
archiveArtifacts 'app/dist/*.exe'
}
}Package.json脚本:
"build": "ng build --prod",
"postbuild": "electron-webpack && electron-builder --x64 --publish=never",https://stackoverflow.com/questions/64890177
复制相似问题