google cloud build-functions @:引擎“节点”与此模块不兼容。预期版本“ 10”

时间:2019-11-10 19:33:28

标签: node.js yaml continuous-deployment google-cloud-build google-cloud-repository

我正在设置云构建触发器,如何正确设置节点版本?这就是我得到的:

  

已经有图像(带有摘要):gcr.io/cloud-builders/yarn       纱线安装v1.9.4       信息找不到锁文件。       发现警告package-lock.json。您的项目包含生成的锁定文件       用纱线以外的工具。建议不要按顺序混合包管理器       以避免由未同步的锁定文件引起的分辨率不一致。至       清除此警告,删除package-lock.json。        [1/5]正在验证package.json ...       错误功能@:引擎“节点”与此模块不兼容。       预期版本为“ 10”。       错误发现不兼容的模块       信息请访问https://yarnpkg.com/en/docs/cli/install以获取有关的文档       该命令。

package.json:

"engines": {
  "node": "10"
}

.yaml是:

steps:
  - name: 'gcr.io/cloud-builders/yarn'
  args: ['install']
  dir: 'functions/autodeploy'

  - name: 'gcr.io/cloud-builders/npm'
  args: ['test']
  dir: 'functions/autodeploy'

  - name: 'gcr.io/cloud-builders/gcloud'
  args: ['functions', 'deploy', 'someName', '--trigger-topic', 
         'some.topic.name', '--runtime', 'nodejs10']
  dir: 'functions/autodeploy'

2 个答案:

答案 0 :(得分:0)

解决方案实现了在评论中进行讨论,总结了解决问题的方式:

  • yarn中使用app.yaml参数--ignore-engines
  • 在构建yaml文件步骤中指定节点版本,因此如下所示:

    steps:
    - name: 'gcr.io/cloud-builders/yarn:node-10.10.0'
      args: ['install', '--ignore-engines']
      dir: 'functions/autodeploy'
    
    - name: 'gcr.io/cloud-builders/npm:node-10.10.0'
      args: ['test']
      dir: 'functions/autodeploy'
    
    - name: 'gcr.io/cloud-builders/gcloud'
      args: ['functions', 'deploy', 'someName', '--trigger-topic', 
      'some.topic.name', '--runtime', 'nodejs10']
      dir: 'functions/autodeploy'
    

答案 1 :(得分:0)

我有同样的错误,删除文件yarn.lock解决了问题