我正在尝试在 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.
容器内构建器:
这还不是全部,因为在这个畸形秀中,几分钟(现在:几小时):
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 中的某种竞争条件