How to Generate Protobuf/ts-proto Code in CI
ts-proto is a protoc plugin, so CI needs the protoc compiler on PATH plus the plugin wired up before any TypeScript is generated.
Generating gRPC/Protobuf TypeScript means two pieces: the protoc binary (a system tool) and the ts-proto npm plugin. Missing the compiler is the most common CI failure.
Why it fails in CI
- protoc is not installed on the runner →
protoc: command not found. - The ts-proto plugin path is wrong, so protoc cannot find it.
- A protoc/plugin version skew produces invalid or empty output.
Install and run it reliably
Install protoc, install ts-proto, then invoke protoc with the plugin path pointed at the local binary. Pin the protoc version for reproducible output.
Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y protobuf-compiler
# (or download a pinned protoc release for an exact version)
npm install ts-proto
protoc \
--plugin=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out=./src/generated \
./proto/service.protoCache & speed
Cache ~/.npm for the plugin. If you download a pinned protoc, cache it keyed on the version so it is not refetched.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}Common errors
protoc: command not found→ installprotobuf-compileror a pinned protoc.--ts_proto_out: protoc-gen-ts_proto: Plugin failed→ wrong--pluginpath; point atnode_modules/.bin.- Empty/partial output → protoc and ts-proto version skew; pin both.
Key takeaways
- CI needs both the protoc compiler and the ts-proto npm plugin.
- Point
--pluginat the localprotoc-gen-ts_protobinary. - Pin protoc for reproducible generated code.
Related guides
How to Run gRPC for Node in CI with Generated StubsRun gRPC for Node in CI end to end: use @grpc/grpc-js, generate stubs with proto-loader or protoc, cache, and…
How to Install gRPC for Node in CI (@grpc/grpc-js)Install gRPC for Node reliably in CI: prefer the pure-JS @grpc/grpc-js over the deprecated native grpc packag…
How to Run esbuild in CI Across PlatformsRun esbuild in CI: let the correct platform binary install via optional dependencies, avoid cross-platform lo…
Self-Healing CI: Missing System Packages and Setup GapsA missing system library or tool fails the build until someone installs it. See the manual fix and how self-h…