1

我正在试一试 Yarn 2/Berry,但我无法弄清楚如何运行由软件包安装的二进制文件。

我专门尝试运行 GRPC 打字稿编译。我在与 Yarn 1 一起使用的 bash 脚本中有以下命令:

yarn run grpc_tools_node_protoc \
    --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
    --ts_out=grpc_js:${PROTO_DEST} \
    --js_out=import_style=commonjs,binary:${PROTO_DEST} \
    --grpc_out=grpc_js:${PROTO_DEST} \
    -I ./protos \
    protos/*.proto

但是当我搬到 Yarn 2/Berry 时,我得到一个./node_modules/.bin/protoc-gen-ts不存在的错误:

./node_modules/.bin/protoc-gen-ts: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--ts_out: protoc-gen-ts: Plugin failed with status code 1.
/Users/paymahn/freenytapp/backend/.yarn/unplugged/grpc-tools-npm-1.11.2-665337de26/node_modules/grpc-tools/bin/protoc.js:41
    throw error;

当我运行时,yarn bin我看到以下内容:

 ❯❯❯ yarn bin
➤ YN0000: eslint
➤ YN0000: grpc_tools_node_protoc
➤ YN0000: grpc_tools_node_protoc_plugin
➤ YN0000: protoc-gen-ts
➤ YN0000: tsc
➤ YN0000: tsserver
➤ YN0000: Done in 0s 19ms

当我跑步时,yarn bin protoc-gen-ts我看到

 ❮❮❮ yarn bin protoc-gen-ts
/Users/paymahn/freenytapp/backend/.yarn/cache/grpc_tools_node_protoc_ts-npm-5.3.0-fa422555f1-efcdb0b83f.zip/node_modules/grpc_tools_node_protoc_ts/bin/protoc-gen-ts

它告诉我二进制文件安装在一个 zip 文件中(假设我没看错)。我怎样才能像在它所在的经典纱线中一样“公开”这个二进制文件node_modules/.bin

4

0 回答 0