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

ivqmmu1c  于 12个月前  发布在  Gulp
关注(0)|答案(1)|浏览(162)

我在React App中有gulpfile.js。
在Azure Pipeline中,我有3个任务

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

但这里我得到下面的错误x1c 0d1x

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

然后得到下面的错误

请帮帮我谢谢你的帮助

pvabu6sv

pvabu6sv1#

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

我的Reactapp仓库,带有gulpfile.js:-

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

我已经将文件路径添加到我的gulpfile.js和react app中,然后在运行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)

输出:-

相关问题