protoc - Protocol Buffer Compiler

raw JSON →
25.9.0 verified Fri May 01 auth: no javascript

Provides the protoc binary for compiling Protocol Buffers (.proto) files to various languages. Current stable version is v34.1.0 (corresponding to upstream v34.1). Released in sync with official protobuf releases; installs platform-specific binary (Linux, macOS, Windows) via npm. Differentiators: eliminates manual download and path setup, integrates with npm workflows, uses npx for simple execution. Requires Node.js >=20.0.0. Not a full protobuf runtime; only the compiler.

error Error: Cannot find module 'protoc'
cause Using require('protoc') in a CommonJS environment.
fix
Use ESM or use npx to run protoc via CLI.
error 'protoc' is not recognized as an internal or external command
cause Attempting to run protoc without npx or not installed.
fix
Run: npx protoc --version
error Error: Failed to execute protoc (error code: 1)
cause Protobuf compilation error often due to missing imports or syntax issues.
fix
Check .proto file syntax, paths, and installed proto dependencies.
gotcha npx protoc may not work if global protoc is installed and on PATH.
fix Use npx --no-install protoc --version or specify full path.
deprecated On Windows, the binary path may have spaces or require special quoting.
fix Use double quotes or escape properly.
gotcha The package only provides the compiler, not runtime libraries for specific languages.
fix Install separate protobuf runtime packages (e.g., protobufjs for JavaScript).
gotcha Electron or bundled apps may need to manually include the binary.
fix Mark protoc as external or copy binary manually.
npm install protoc
yarn add protoc
pnpm add protoc

Install protoc as a dev dependency and verify the version.

npm install --save-dev protoc
npx protoc --version