Registry / devops / grpc-tools

grpc-tools

JSON →
library1.13.1jsnpmunverified

Distributes the Protocol Buffers compiler protoc and the Node.js gRPC plugin for generating client/server stubs. Current version 1.13.1. Released as part of grpc-node monorepo. Key differentiator: provides protoc binary and gRPC plugin in one npm package, eliminating need to install protoc separately. Supports generating code for grpc or @grpc/grpc-js, and package definition generation. Alternative to maintaining manual protoc installations.

npm install grpc-tools
INSTALL
IMPORT
SIG · GRPC-TOOLS
G
grpc-tools
devopsjavascriptv1.13.1
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.

grpc_tools_node_protoc
const grpc_tools_node_protoc = require('grpc-tools').grpc_tools_node_protoc;
import { grpc_tools_node_protoc } from 'grpc-tools';
This package does not export ES modules; use require() for CommonJS.
binaryPath
const { binaryPath } = require('grpc-tools');
const binaryPath = require('grpc-tools').binaryPath;
binaryPath is a named export, not a property of default export.
grpc_tools_node_protoc (binary path)
const binPath = require('grpc-tools').binaryPath; const protoc = require('child_process').spawn(binPath, ['--version']);
const protoc = require('grpc-tools').binaryPath.spawn(...);
binaryPath is a string path, not a node module; use child_process.spawn to execute.

Run protoc with Node gRPC plugin to generate JS stubs from a .proto file, outputting in commonjs style and using @grpc/grpc-js.

const { grpc_tools_node_protoc } = require('grpc-tools'); const { execSync } = require('child_process'); // Generate JavaScript code from proto file using @grpc/grpc-js const result = execSync( `${grpc_tools_node_protoc} --js_out=import_style=commonjs,binary:. --grpc_out=grpc_js:. -I. ./example.proto`, { encoding: 'utf-8' } ); console.log('Generated files:', result);
Debug
Known issues
breakingIn version 1.12.0 and later, the binary path behavior changed when installed as a dependency, requiring use of binaryPath export.
fix
Use require('grpc-tools').binaryPath to locate the binary.
affects: >=1.12.0
gotchaThe protoc binary may not be executable on all platforms (e.g., missing permissions) leading to EACCES errors.
fix
Run chmod +x on the binary path from binaryPath, or use node-pre-gyp to reinstall.
affects: all
deprecatedThe option `grpc` for --grpc_out (using the old grpc npm package) is deprecated; prefer `grpc_js` for @grpc/grpc-js.
fix
Use --grpc_out=grpc_js: instead of --grpc_out:
affects: >=1.8.0
gotchaThe protoc binary provided by this package is for the host platform only; cross-compilation or platform-specific issues may occur.
fix
Use a separate protoc installation if targeting different platforms.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'grpc-tools/build/bin/protoc'
The package did not install binaries successfully (node-gyp failure or missing platform support).
fix
Reinstall the package: npm rebuild grpc-tools or remove node_modules and npm install.
Error: EACCES: permission denied, stat '/path/to/grpc-tools/build/bin/protoc'
Protoc binary lacks execute permissions.
fix
Run: chmod +x $(node -e "console.log(require('grpc-tools').binaryPath)")
Error: unknown flag: --grpc_out
Using an older version of grpc-tools that doesn't support --grpc_out flag (or using wrong binary).
fix
Upgrade to version >=1.8.0: npm install grpc-tools@latest
Upgrade
Version history
1.13.1latest on npm
Audit
Dependencies
node-gyprequiredInstalls native binaries via node-pre-gyp or node-gyp
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-tools — npm install grpc-tools · libregistry