Registry / serialization / protoc

protoc

JSON →
library25.9.0jsnpmunverified

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.

npm install protoc
INSTALL
IMPORT
SIG · PROTOC
P
protoc
serializationjavascriptv25.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

protoc
npx protoc --version
protoc --version
Use npx to resolve the binary installed in node_modules/.bin.
protoc
import { protoc } from 'protoc'
const protoc = require('protoc')
Package is ESM-only as of v3. CommonJS require will fail. Compiles .proto files; does not export a default binary.
protocPath
import { protocPath } from 'protoc'
Exporting the path to the protoc binary for programmatic use.

Install protoc as a dev dependency and verify the version.

npm install --save-dev protoc npx protoc --version
protoc --version
Debug
Known issues
gotchanpx protoc may not work if global protoc is installed and on PATH.
fix
Use npx --no-install protoc --version or specify full path.
affects: >=1.0.0
deprecatedOn Windows, the binary path may have spaces or require special quoting.
fix
Use double quotes or escape properly.
affects: >=1.0.0
gotchaThe package only provides the compiler, not runtime libraries for specific languages.
fix
Install separate protobuf runtime packages (e.g., protobufjs for JavaScript).
affects: >=1.0.0
gotchaElectron or bundled apps may need to manually include the binary.
fix
Mark protoc as external or copy binary manually.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'protoc'
Using require('protoc') in a CommonJS environment.
fix
Use ESM or use npx to run protoc via CLI.
'protoc' is not recognized as an internal or external command
Attempting to run protoc without npx or not installed.
fix
Run: npx protoc --version
Error: Failed to execute protoc (error code: 1)
Protobuf compilation error often due to missing imports or syntax issues.
fix
Check .proto file syntax, paths, and installed proto dependencies.
Upgrade
Version history
25.9.0latest on npm
Audit
Dependencies
nodeoptionalRuntime dependency: requires Node.js >=20.0.0 to run the npm package.
Agent activity
6 hits · last 30 days
node
6
Resources
protoc — npm install protoc · libregistry