{"id":26114,"library":"protoc","title":"protoc - Protocol Buffer Compiler","description":"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.","status":"active","version":"25.9.0","language":"javascript","source_language":"en","source_url":"https://github.com/timostamm/protobuf-npm","tags":["javascript","Protocol Buffers","protobuf","protoc","installation"],"install":[{"cmd":"npm install protoc","lang":"bash","label":"npm"},{"cmd":"yarn add protoc","lang":"bash","label":"yarn"},{"cmd":"pnpm add protoc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency: requires Node.js >=20.0.0 to run the npm package.","package":"node","optional":true}],"imports":[{"note":"Use npx to resolve the binary installed in node_modules/.bin.","wrong":"protoc --version","symbol":"protoc","correct":"npx protoc --version"},{"note":"Package is ESM-only as of v3. CommonJS require will fail. Compiles .proto files; does not export a default binary.","wrong":"const protoc = require('protoc')","symbol":"protoc","correct":"import { protoc } from 'protoc'"},{"note":"Exporting the path to the protoc binary for programmatic use.","wrong":"","symbol":"protocPath","correct":"import { protocPath } from 'protoc'"}],"quickstart":{"code":"npm install --save-dev protoc\nnpx protoc --version","lang":"javascript","description":"Install protoc as a dev dependency and verify the version."},"warnings":[{"fix":"Use npx --no-install protoc --version or specify full path.","message":"npx protoc may not work if global protoc is installed and on PATH.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use double quotes or escape properly.","message":"On Windows, the binary path may have spaces or require special quoting.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install separate protobuf runtime packages (e.g., protobufjs for JavaScript).","message":"The package only provides the compiler, not runtime libraries for specific languages.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Mark protoc as external or copy binary manually.","message":"Electron or bundled apps may need to manually include the binary.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use ESM or use npx to run protoc via CLI.","cause":"Using require('protoc') in a CommonJS environment.","error":"Error: Cannot find module 'protoc'"},{"fix":"Run: npx protoc --version","cause":"Attempting to run protoc without npx or not installed.","error":"'protoc' is not recognized as an internal or external command"},{"fix":"Check .proto file syntax, paths, and installed proto dependencies.","cause":"Protobuf compilation error often due to missing imports or syntax issues.","error":"Error: Failed to execute protoc (error code: 1)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}