0

我正在尝试在 gcloud 上构建一些东西,特别是一个带有 Yarn 和 Node 的网站。

这是我要运行的脚本:

"build:langs": "printenv && ls -lah node_modules/.bin && BABEL_ENV=test babel-node scripts/translate.js",

通过

$ yarn run build:langs

哪个输出https://gist.github.com/haf/ebc623bfce5520432c136e44496b58fb - 这里有趣的位(为便于阅读而格式化):

Step #2 - "js-build-langs": 
PATH=/workspace/src/site.com/node_modules/.bin
  :/usr/local/share/.config/yarn/link/node_modules/.bin
  :/workspace/src/
...
total 40K
Step #2 - "js-build-langs": drwxr-xr-x 2 root root 4.0K Jun 3 19:18 .
Step #2 - "js-build-langs": drwxr-xr-x 1194 root root 36K Jun 3 19:19 ..
Step #2 - "js-build-langs": lrwxrwxrwx 1 root root 20 Jun 3 19:18 JSONStream -> ../JSONStream/bin.js
Step #2 - "js-build-langs": lrwxrwxrwx 1 root root 19 Jun 3 19:18 _mocha -> ../mocha/bin/_mocha
...
Step #2 - "js-build-langs": lrwxrwxrwx 1 root root 30 Jun 3 19:18 babel-node -> ../babel-cli/bin/babel-node.js
...
Step #2 - "js-build-langs": /bin/sh: 1: babel-node: not found
Step #2 - "js-build-langs": error Command failed with exit code 127.
Step #2 - "js-build-langs": info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

容器内构建器:

显示来自 Google Container Builder 的输出

这还不是全部,因为在这个畸形秀中,几分钟(现在:几小时):

在此处输入图像描述

cloudbuild 目标如下所示:

steps:
# JS from https://console.cloud.google.com/gcr/images/cloud-builders/GLOBAL/yarn?gcrImageListsize=50:
- name: gcr.io/cloud-builders/yarn:node-8.11.0
  waitFor: ["-"]
  id: js-install
  dir: src/site.com
  args: ["install"]

- name: gcr.io/cloud-builders/yarn:node-8.11.0
  waitFor: ["js-install"]
  id: js-build-prod
  dir: src/site.com
  args: ["run", "build:prod"]

- name: gcr.io/cloud-builders/yarn:node-8.11.0
  waitFor: ["js-build-prod"]
  id: js-build-langs
  dir: src/site.com
  args: ["run", "build:langs"]

和 packages.json 片段:

  "devDependencies": {
    "@babel/core": "^7.0.0-beta.49",
    "@babel/node": "^7.0.0-beta.49",

总而言之,我很困惑。尽管 PATH 包含二进制 js 文件,但为什么它不起作用,该文件是可执行的?为什么它可以找到 webpack 而不是 babel-node?为什么即使在 full 之后我也可以在本地运行它git clean -fxd?为什么它有时会起作用,但有时却不起作用?

我的直觉告诉我这是 GCB 中的某种竞争条件

4

2 回答 2

1

编辑3:这对我们来说偶尔会出现,这是我们目前的想法。

当我们&&在 package.json 中链接 yarn-commands 时,会导致创建 egnode_modules/mocha/bin/mocha.js或其他可执行 js 文件时出现问题。

我们将 packages.json 中的每个命令都设为非链接和清理node_modules。现在至少已经完成了一个构建。

谷歌搜索'127 command not found'和'yarn'没有给出任何提示。

于 2018-06-07T16:14:09.170 回答
0

当您在托管的Google Container Builder上运行时,在构建步骤中共享的唯一数据是共享/workspace目录中的数据(以及配置的 volumes,但您没有在您提供的代码段中使用任何数据)。

我不是 npm 或纱线专家——但你的任何包是否在 package.json 配置中更改了它们的 node_modules 位置?请注意,yarn install需要一个--modules-folder选项,这可能会有所帮助。

于 2018-06-04T18:41:06.057 回答