gpt4 book ai didi

javascript - 在 yaml 中的 gulp 任务中设置 --max_old_space_size

转载 作者:行者123 更新时间:2023-12-03 06:07:27 25 4
gpt4 key购买 nike

我在 React 应用程序中有 gulpfile.js。

在 Azure Pipeline 中,我有 3 个任务

  • 安装 Node 版本
  • 安装 npm
  • 运行gulp
      displayName: Run gulp
inputs:
gulpFile: ${{parameters.gulpFilePath}}
targets:
arguments: 'production'
gulpjs: 'node_modules/gulp/bin/gulp.js'
enableCodeCoverage: false

但是我遇到了以下错误 Javascript heap out of memory error

I followed from stackoverflow as well

但无法理解我必须在我的 gulp 任务中添加这行代码--max_old_space_size=4096

我尝试添加几种不同的方式,但总是失败。我还传递了如下脚本

task: PowerShell@2
displayName: Run npm install
inputs:
targetType: 'inline'
script: |
cd ${{parameters.reactAppPath}}
npm install
gulp --max_old_space_size=4096 --gulpfile ${{parameters.gulpFilePath}} production

然后出现以下错误 enter image description here

请帮帮我感谢您的帮助

最佳答案

当您的 Pipeline 无法在存储库中找到 gulpfile.js 时,会出现 No gulp file found 错误。

我的带有 gulpfile.js 的 Reactapp 存储库:-

enter image description here

用于安装和运行 gulp 的 Azure yaml 代码:-

我已将文件路径添加到变量中的 gulpfile.js 和 React 应用程序,然后在运行 gulp 任务中引用它,如下所示:-

variables:
gulpFilePath: '$(System.DefaultWorkingDirectory)/gulpfile.js'
reactAppPath: '$(System.DefaultWorkingDirectory)'
.
.
.
.. cd $(reactAppPath)
node --max_old_space_size=4096 ./node_modules/gulp/bin/gulp.js --gulpfile $(gulpFilePath)

完整的yaml代码:-

trigger:
- '*'

pr:
- '*'

pool:
vmImage: 'ubuntu-latest'

variables:
gulpFilePath: '$(System.DefaultWorkingDirectory)/gulpfile.js'
reactAppPath: '$(System.DefaultWorkingDirectory)'

steps:
- task: UseNode@1
displayName: 'Install Node.js'
inputs:
version: '18.x'

- script: npm install -g npm@latest
displayName: 'Upgrade npm'

- script: npm install -g timers-promises
displayName: 'Upgrade npm'

- script: npm install --save-dev gulp gulp-babel gulp-browserify gulp-plumber gulp-sourcemaps babelify vinyl-source-stream
displayName: 'Upgrade npm'

# - script: npm install --global gulp
# displayName: 'Install Gulp globally'

- task: PowerShell@2
displayName: 'Run npm install'
inputs:
targetType: 'inline'
script: |
cd $(reactAppPath)
npm install

- task: PowerShell@2
displayName: 'Run Gulp'
inputs:
targetType: 'inline'
script: |
cd $(reactAppPath)
node --max_old_space_size=4096 ./node_modules/gulp/bin/gulp.js --gulpfile $(gulpFilePath)

输出:-

enter image description here

关于javascript - 在 yaml 中的 gulp 任务中设置 --max_old_space_size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77177791/

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