gpt4 book ai didi

node.js - Azure 构建上的 JavaScript 堆内存不足

转载 作者:行者123 更新时间:2023-12-02 22:56:06 25 4
gpt4 key购买 nike

我正在将 aspnetboilerplate 与 Angular 和 .NET Core 结合使用。当我尝试在 Azure 上部署应用程序时,它显示:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

这是我的 azure 管道:

trigger:
- master

pool:
vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'

- script: |
npm install -g @angular/cli
npm install
npm run build-prod
ng build --c=production
displayName: 'npm install and build'

- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)/dist'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
OverWrite: true

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'

并在 package.json 文件中添加了 build-prod 属性。

"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 4200",
"hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"lint": "tslint --force --project src/tsconfig.json src/**/*.ts -t verbose",
"build-prod": "node --max-old-space-size=8000 ./node_modules/@angular/cli/bin/ng"
},

最佳答案

Azure DevOps 中的 Azure Pipeline 解决方案:

- task: PowerShell@2
displayName: Build
env:
NODE_OPTIONS: --max_old_space_size=16384

在构建任务中将环境变量 NODE_OPTIONS 设置为值 --max_old_space_size=16384

关于node.js - Azure 构建上的 JavaScript 堆内存不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60509976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com