{"id":47990,"library":"grpc-alt-proto-loader","title":"@grpc/proto-loader","description":"Utility package for loading .proto files for gRPC, using Protobuf.js. Version 0.5.0 runs on Node >=6 and ships TypeScript types. It provides both async (load) and sync (loadSync) loading of protobuf definitions, returning a package definition object that can be consumed by gRPC libraries (grpc or @grpc/grpc-js). Supports options like keepCase, longs, enums, bytes, defaults, arrays, objects, oneofs, and includeDirs. It is the recommended replacement for the deprecated grpc.load(). Community-maintained, part of the grpc-node monorepo.","status":"active","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/grpc/grpc-node","tags":["javascript","typescript"],"install":[{"cmd":"npm install grpc-alt-proto-loader","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-alt-proto-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-alt-proto-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for parsing .proto files","package":"protobufjs","optional":false},{"reason":"Used for camelCase conversion of field names when keepCase is false","package":"lodash.camelcase","optional":false}],"imports":[{"note":"ESM named export. Also available as a property of the default export in CommonJS.","wrong":"const protoLoader = require('@grpc/proto-loader'); const load = protoLoader.default.load;","symbol":"load","correct":"import { load } from '@grpc/proto-loader'"},{"note":"Valid both as ESM named import and CommonJS destructure.","wrong":"const { loadSync } = require('@grpc/proto-loader');","symbol":"loadSync","correct":"import { loadSync } from '@grpc/proto-loader'"},{"note":"Default export is an object with load and loadSync functions. CommonJS require returns the same object, not a default property.","wrong":"const protoLoader = require('@grpc/proto-loader').default;","symbol":"default export","correct":"import protoLoader from '@grpc/proto-loader'"},{"note":"TypeScript type export, only available as a type import.","wrong":null,"symbol":"GrpcObject","correct":"import type { GrpcObject } from '@grpc/proto-loader'"}],"quickstart":{"code":"import { loadSync } from '@grpc/proto-loader';\nimport { loadPackageDefinition, credentials } from '@grpc/grpc-js';\n\nconst packageDefinition = loadSync('helloworld.proto', {\n  keepCase: true,\n  longs: String,\n  enums: String,\n  defaults: true,\n  oneofs: true,\n});\nconst helloProto = loadPackageDefinition(packageDefinition).helloworld;\nconst client = new helloProto.Greeter('localhost:50051', credentials.createInsecure());\nclient.sayHello({ name: 'world' }, (err, response) => {\n  console.log('Greeting:', response.message);\n});","lang":"typescript","description":"Loads a .proto file synchronously and creates a gRPC client using @grpc/grpc-js."},"warnings":[{"fix":"Always use grpc.loadPackageDefinition (or @grpc/grpc-js equivalent) to convert the result.","message":"load() and loadSync() return package definitions compatible with grpc.loadPackageDefinition, but the format differs from grpc.load() output.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use @grpc/grpc-js instead of grpc.","message":"The 'grpc' package (non-@grpc) is deprecated in favor of @grpc/grpc-js.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Set keepCase: true to preserve original field names.","message":"Options keepCase: false (default) converts field names to camelCase, which may break existing code expecting original names.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use longs: Number for 64-bit integers within safe integer range, or leave default (Long object) for full precision.","message":"Using longs: String converts Long values to strings, which may lose numeric precision for very large numbers.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Explicitly set enums: String if you need names, or leave default for numbers.","message":"The enum option defaults to numeric values; setting enums: String returns enum names instead.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.5.0':13 '6':17 'array':57 'async':25 'byte':55 'communiti':72 'community-maintain':71 'consum':42 'default':56 'definit':33,37 'deprec':69 'enum':54 'file':7 'grpc':9,44,46,78 'grpc-node':77 'grpc.load':70 'grpc/grpc-js':48 'grpc/proto-loader':1 'includedir':61 'javascript':81 'keepcas':52 'librari':45 'like':51 'load':5,26,30 'loadsync':29 'long':53 'maintain':73 'monorepo':80 'node':16,79 'object':38,58 'oneof':59 'option':50 'packag':3,36 'part':74 'proto':6 'protobuf':32 'protobuf.js':11 'provid':23 'recommend':65 'replac':66 'return':34 'run':14 'ship':19 'support':49 'sync':28 'type':21 'typescript':20,82 'use':10 'util':2 'version':12","created_at":"2026-06-07T16:54:22.130831+00:00","updated_at":"2026-06-07T16:54:22.130831+00:00","problems":[{"fix":"Always pass the package definition to grpc.loadPackageDefinition (or @grpc/grpc-js equivalent).","cause":"The result of load/loadSync was directly used as a gRPC object without calling loadPackageDefinition.","error":"Error: Package definition is not a valid gRPC package definition"},{"fix":"Install: npm install @grpc/proto-loader","cause":"Package not installed, or using wrong import path.","error":"Cannot find module '@grpc/proto-loader'"},{"fix":"Use const { loadSync } = require('@grpc/proto-loader'); or const protoLoader = require('@grpc/proto-loader'); then protoLoader.loadSync().","cause":"CommonJS require returns the module exports directly; the function is named loadSync.","error":"TypeError: protoLoader.loadSync is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://grpc.io/","github":"https://github.com/grpc/grpc-node","docs":null,"changelog":null,"pypi":null,"npm":"grpc-alt-proto-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}