在 Azure 管道上安装 npm 期间 JavaScript 堆内存不足

问题描述 投票:0回答:1

我最近将我的

angular projects
angular 16
更新为
ngular 17
npm install
与我的笔记本电脑上的
angular 17
完美配合。但在 Azure 管道上,它会抛出错误:-

 "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory".

我该如何解决这个问题?

在一个存储库中,我通过将

"npm install"
作为脚本更改为
"npm install"
作为内置任务来解决此问题:
Npm@1

但它在另一个仓库中不起作用。我还在

package-lock.json
之前删除了
npm install
,但没有帮助。

javascript azure npm npm-install
1个回答
0
投票

您需要在

nodejs
中使用以下脚本来增加
yaml code
的内存分配:-

trigger:
  - main

pool:
  vmImage: ubuntu-latest

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

  - script: |
      NODE_OPTIONS="--max-old-space-size=4096" npm install
    displayName: 'npm install with increased memory'

  - script: |
      npm cache clean --force
    displayName: 'Clear npm cache'

  - script: |
      npm install --only=dev
    displayName: 'Install dev dependencies'

输出:-

enter image description here

参考我的SO答案

© www.soinside.com 2019 - 2024. All rights reserved.