Registry / devops / protobufts

protobufts

JSON →
library0.3.1jsnpmunverified

Protobufts (version 0.3.1) is a TypeScript code generator that produces strongly-typed models from Protocol Buffer (.proto) definitions, specifically designed for use with Node.js gRPC. It generates TypeScript interfaces and classes for message types, enums, and services, enabling type-safe gRPC client and server implementations. Unlike generic protobuf JavaScript generators, protobufts outputs idiomatic TypeScript with full type information, reducing runtime errors and improving developer experience. The project is in early stages, with recent releases focused on core functionality and limited customization options.

npm install protobufts
INSTALL
IMPORT
SIG · PROTOBUFTS
P
protobufts
devopsjavascriptv0.3.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.

Message
import { Message } from 'protobufts'
const Message = require('protobufts').Message
Protobufts ships as ESM-only; CommonJS require pattern works but is not recommended.
generateCode
import { generateCode } from 'protobufts'
import generateCode from 'protobufts'
generateCode is a named export, not a default export.
TypeMap
import type { TypeMap } from 'protobufts'
import { TypeMap } from 'protobufts'
TypeMap is a TypeScript type, best imported with `import type` to avoid runtime bundling.

Generates TypeScript models from a .proto file and writes them to a .ts file.

import { generateCode } from 'protobufts'; import { readFileSync, writeFileSync } from 'fs'; const protoContent = readFileSync('./example.proto', 'utf-8'); const output = generateCode(protoContent, { noGrpc: false }); writeFileSync('./generated/models.ts', output, 'utf-8'); console.log('TypeScript models generated!');
Debug
Known issues
breakingVersion 0.3.0 changed the generateCode function signature: now requires an options object as second argument.
fix
Update calls to generateCode(protoContent, { noGrpc: false }).
affects: >=0.3.0
deprecatedThe `grpc` option in generateCode is deprecated; use `noGrpc` instead.
fix
Replace { grpc: true } with { noGrpc: false } in options.
affects: >=0.2.0 <0.4.0
gotchaGenerated models require protobufjs at runtime for serialization. Ensure it is installed.
fix
npm install protobufjs as a dependency.
affects: all
gotchaProtobufts only supports proto3 syntax; proto2 files will generate incorrect model types.
fix
Convert proto2 files to proto3 or use other code generators.
affects: all
gotchaService definitions are not fully supported yet; gRPC service stubs may require manual implementation.
fix
Check the generated output and manually fill in any missing service code.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'protobufjs'
Runtime dependency protobufjs is not installed.
fix
Install protobufjs: npm install protobufjs
TypeError: generateCode is not a function
Default import used instead of named import.
fix
Use named import: import { generateCode } from 'protobufts'
Error: Invalid proto definition: syntax "proto2" not supported
Only proto3 syntax is supported.
fix
Update your .proto file to use syntax = "proto3";
Cannot read properties of undefined (reading 'fields')
Generated model missing required protobufjs runtime.
fix
Ensure protobufjs is installed and imported in your project before using generated models.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
protobufjsrequiredRuntime serialization/deserialization of Protocol Buffers
Agent activity
6 hits · last 30 days
node
6
Resources
protobufts — npm install protobufts · libregistry