[Bug]:在运行yarn build-storybook(Docker)时,找不到yarn v3 "@esbuild/linux-x64"

2eafrhcq  于 3个月前  发布在  Yarn
关注(0)|答案(4)|浏览(50)

在Docker容器中运行storybook build时,遇到了一个错误,提示缺少@esbuild/linux64包,该包是esbuild所需的。尝试使用不同的node镜像后,问题仍然存在。当手动添加该包后,一切正常。使用npm时也正常工作。

错误信息:

The package "@esbuild/linux-x64" could not be found, and is needed by esbuild.
If you are installing esbuild with npm, make sure that you don't specify the
 "--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
 of "package.json" is used by esbuild to install the correct binary executable
 for your current platform.
 at generateBinPath (/app/.yarn/unplugged/esbuild-npm-0.17.14-fb0460a0aa/node_modules/esbuild/lib/main.js:1885:15)
 at esbuildCommandAndArgs (/app/.yarn/unplugged/esbuild-npm-0.17.14-fb0460a0aa/node_modules/esbuild/lib/main.js:1955:33)
 at ensureServiceIsRunning (/app/.yarn/unplugged/esbuild-npm-0.17.14-fb0460a0aa/node_modules/esbuild/lib/main.js:2119:25)
 at startSyncServiceWorker (/app/.yarn/unplugged/esbuild-npm-0.17.14-fb0460a0aa/node_modules/esbuild/lib/main.js:2322:19)
 at Object. (/app/.yarn/unplugged/esbuild-npm-0.17.14-fb0460a0aa/node_modules/esbuild/lib/main.js:2363:3)
 at Module._compile (node:internal/modules/cjs/loader:1275:14)
 at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
 at require$$0.Module._extensions..js (/app/.pnp.cjs:21863:33)
 at Module.load (node:internal/modules/cjs/loader:1133:32)
 at require$$0.Module._load (/app/.pnp.cjs:21682:22)
r8uurelv

r8uurelv1#

我想知道这是否是由于在一个平台上创建了锁文件,然后在另一个平台上安装了node_modules。ESBuild有时会遇到这种情况...
你可以尝试做的一件事是删除你的yarn.locknode_modules,然后重新安装以重新生成锁文件。

rn0zuynd

rn0zuynd2#

遗憾的是,这也不起作用。我还尝试在Docker容器中创建yarn.lock,并仅将package.json复制到容器中。

ws51t4hk

ws51t4hk3#

你可以尝试以下解决方案:https://esbuild.github.io/getting-started/#simultaneous-platforms

aoyhnmkz

aoyhnmkz4#

同样的问题,我在Mac上运行yarn,然后上传到Linux CI(node:16-alpine3.17)。我尝试了esbuild建议的支持的架构,但问题仍然存在,甚至尝试指定包扩展名。还尝试了最激进的方法,即删除yarn.lock,清除缓存,重建并安装,但也没有成功。

CI似乎找不到esbuild包,因为当我拦截管道并运行yarn add -D @esbuild/linux-x64时,它会删除已上传的包并从注册表重新下载,如下图所示的Fetch step。然后由于esbuild未成功构建,导致安装失败。我之所以说是失败,是因为我在CI上运行了yarn storybook build,尽管yarn出错,但它仍然可以工作。

我尝试在运行Storybook之前将yarn add -D @esbuild/linux-x64添加到CI步骤中,但由于yarn错误,它在运行之前退出。

失败的esbuild步骤的日志

CI - ls .yarn/cache/ | grep esbuild

手动添加esbuild包后

➤ YN0000: ┌ Fetch step
➤ YN0013: │ @esbuild/linux-x64@npm:0.18.11 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @esbuild/linux-x64@npm:0.17.19 can't be found in the cache and will be fetched from the remote registry
➤ YN0019: │ @esbuild-linux-x64-npm-0.17.19-08a7136aa6-03ff211ae0.zip appears to be unused - removing
➤ YN0019: │ @esbuild-linux-x64-npm-0.18.11-b588f18037-8.zip appears to be unused - removing
➤ YN0000: └ Completed in 3s 845ms

➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ @apollo/protobufjs@npm:1.2.6 must be built because it never has been before or the last one failed
➤ YN0007: │ @apollo/protobufjs@npm:1.2.7 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:3.8.3 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.18.11 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:3.6.4 must be built because it never has been before or the last one failed
➤ YN0007: │ protobufjs@npm:6.11.3 must be built because it never has been before or the last one failed
➤ YN0007: │ esbuild@npm:0.17.19 must be built because it never has been before or the last one failed
➤ YN0007: │ @swc/core@npm:1.3.53 [b02d5] must be built because it never has been before or the last one failed
➤ YN0007: │ msw@npm:1.2.1 [b02d5] must be built because it never has been before or the last one failed
➤ YN0009: │ esbuild@npm:0.18.11 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-4463af5b/build.log)
➤ YN0009: │ esbuild@npm:0.17.19 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-388c1661/build.log)
➤ YN0007: │ now-xtv@workspace:. must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 5s 467ms
➤ YN0000: Failed with errors in 10s 331ms

Log from the failed `esbuild` step

This file contains the result of Yarn building a package (esbuild@npm:0.17.19)

Script name: postinstall

[esbuild] Failed to find package "@esbuild/linux-x64" on the file system

This can happen if you use the "--no-optional" flag. The "optionalDependencies"
package.json feature is used by esbuild to install the correct binary executable
for your current platform. This install script will now attempt to work around
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.

[esbuild] Trying to install package "@esbuild/linux-x64" using npm
node:internal/errors:857
const err = new Error(message);
^

Error: Command failed: /usr/local/bin/node /tmp/build/1e48fc67/project/.yarn/unplugged/esbuild-npm-0.17.19-f690397756/node_modules/esbuild/bin/esbuild --version
/tmp/build/1e48fc67/project/.pnp.cjs:43379
return Object.defineProperties(new Error(message), {
^

Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed.

Source path: /tmp/build/1e48fc67/project/.yarn/unplugged/esbuild-npm-0.17.19-f690397756/node_modules/esbuild/bin/esbuild
Not found: /tmp/build/1e48fc67/project/.yarn/unplugged/esbuild-npm-0.17.19-f690397756/node_modules/esbuild/bin/esbuild

at makeError (/tmp/build/1e48fc67/project/.pnp.cjs:43379:34)
at resolveUnqualified (/tmp/build/1e48fc67/project/.pnp.cjs:45194:13)
at resolveRequest (/tmp/build/1e48fc67/project/.pnp.cjs:45235:14)
at Object.resolveRequest (/tmp/build/1e48fc67/project/.pnp.cjs:45291:26)
at resolve$1 (file:///tmp/build/1e48fc67/project/.pnp.loader.mjs:1991:25)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ESMLoader.import (node:internal/modules/esm/loader:521:22)
at node:internal/modules/run_main:58:28

at checkExecSyncError (node:child_process:861:11)
at Object.execFileSync (node:child_process:896:15)
at validateBinaryVersion (/tmp/build/1e48fc67/project/.yarn/unplugged/esbuild-npm-0.17.19-f690397756/node_modules/esbuild/install.js:98:28)
at /tmp/build/1e48fc67/project/.yarn/unplugged/esbuild-npm-0.17.19-f690397756/node_modules/esbuild/install.js:283:5 {

status: 1,
signal: null,
output: [
null,
Buffer(0) [Uint8Array] [],
Buffer(1154) [Uint8Array] [
47, 116, 109, 112, 47, 98, 117, 105, 108, 100, 47, 49,
101, 52, 56, 102, 99, 54, 55, 47, 112, 114, 111, 106,
101, 99, 116, 47, 46, 112, 110, 112, 46, 99, 106, 115,
58, 52, 51, 51, 55, 57, 10, 32, 32, 114, 101, 116,
117, 114, 110, 32, 79, 98, 106, 101, 99, 116, 46, 100,
101, 102, 105, 110, 101, 80, 114, 111, 112, 101, 114, 116,
105, 101, 115, 40, 110, 101, 119, 32, 69, 114, 114, 111,
114, 40, 109, 101, 115, 115, 97, 103, 101, 41, 44, 32,
123, 10, 32, 32,
... 1054 more items
]
],
pid: 166,
stdout: Buffer(0) [Uint8Array] [],
stderr: Buffer(1154) [Uint8Array] [
47, 116, 109, 112, 47, 98, 117, 105, 108, 100, 47, 49,
101, 52, 56, 102, 99, 54, 55, 47, 112, 114, 111, 106,
101, 99, 116, 47, 46, 112, 110, 112, 46, 99, 106, 115,
58, 52, 51, 51, 55, 57, 10, 32, 32, 114, 101, 116,
117, 114, 110, 32, 79, 98, 106, 101, 99, 116, 46, 100,
101, 102, 105, 110, 101, 80, 114, 111, 112, 101, 114, 116,
105, 101, 115, 40, 110, 101, 119, 32, 69, 114, 114, 111,
114, 40, 109, 101, 115, 115, 97, 103, 101, 41, 44, 32,
123, 10, 32, 32,
... 1054 more items
]
}


On the CI -  `ls .yarn/cache/ | grep esbuild`

@esbuild-darwin-arm64-npm-0.17.19-64d69299ed-8.zip
@esbuild-darwin-arm64-npm-0.18.11-e0ec586879-8.zip
@esbuild-darwin-x64-npm-0.17.19-30afb0190b-8.zip
@esbuild-darwin-x64-npm-0.18.11-0c67bcca93-8.zip
@esbuild-linux-arm64-npm-0.17.19-6f31af48bb-8.zip
@esbuild-linux-arm64-npm-0.18.11-5e3b51d24f-8.zip
@esbuild-linux-x64-npm-0.17.19-08a7136aa6-03ff211ae0.zip
@esbuild-linux-x64-npm-0.18.11-b588f18037-8.zip
@fal-works-esbuild-plugin-global-externals-npm-2.1.2-b50ef0c6e7-c59715902b.zip
@yarnpkg-esbuild-plugin-pnp-npm-3.0.0-rc.15-b916c218b3-04da15355a.zip
esbuild-npm-0.17.19-f690397756-ac11b1a5a6.zip
esbuild-npm-0.18.11-7ebdd30a31-fbd981388f.zip
esbuild-plugin-alias-npm-0.2.1-8906d98875-afe2d2c8b5.zip
esbuild-register-npm-3.4.2-c873c16acc-f65d1ccb58.zip


After adding the esbuild package manually

@esbuild-darwin-arm64-npm-0.17.19-64d69299ed-8.zip
@esbuild-darwin-arm64-npm-0.18.11-e0ec586879-8.zip
@esbuild-darwin-x64-npm-0.17.19-30afb0190b-8.zip
@esbuild-darwin-x64-npm-0.18.11-0c67bcca93-8.zip
@esbuild-linux-arm64-npm-0.17.19-6f31af48bb-8.zip
@esbuild-linux-arm64-npm-0.18.11-5e3b51d24f-8.zip
@esbuild-linux-x64-npm-0.17.19-08a7136aa6-8.zip
@esbuild-linux-x64-npm-0.18.11-b588f18037-797c07c0ab.zip
@fal-works-esbuild-plugin-global-externals-npm-2.1.2-b50ef0c6e7-c59715902b.zip
@yarnpkg-esbuild-plugin-pnp-npm-3.0.0-rc.15-b916c218b3-04da15355a.zip
esbuild-npm-0.17.19-f690397756-ac11b1a5a6.zip
esbuild-npm-0.18.11-7ebdd30a31-fbd981388f.zip
esbuild-plugin-alias-npm-0.2.1-8906d98875-afe2d2c8b5.zip
esbuild-register-npm-3.4.2-c873c16acc-f65d1ccb58.zip

相关问题