improbable-eng / ts-protoc-gen

Protocol Buffers Compiler (protoc) plugin for TypeScript and gRPC-Web.
Apache License 2.0
1.36k stars 172 forks source link

0.8.0 incompatible with protoc 3.7.0 #152

Closed faraonc closed 5 years ago

faraonc commented 5 years ago

Versions of relevant software used "ts-protoc-gen": "0.9.0"

protoc --version
libprotoc 3.7.0
npm -version
6.8.0

What happened Error on using protoc

PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts"

# Directory to write generated code to (.js and .d.ts files) 
OUT_DIR="./generated"

protoc \
    --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
    --js_out="import_style=commonjs,binary:${OUT_DIR}" \
    --ts_out="${OUT_DIR}" \
    hello.proto

What you expected to happen No error

How to reproduce it (as minimally and precisely as possible): Follow the README.md here using a simple proto.

Full logs to relevant components

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'google-protobuf/google/protobuf/descriptor_pb'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/faraonc/go/src/github.com/hwsc-org/hwsc-api-blocks/node_modules/ts-protoc-gen/lib/ts/message.js:4:23)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

Anything else we need to know

I reverted back to 0.8.0 which works fine with protoc 3.7.0

Environment: Happens in both:

NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

AND

macOs Darwin Kernel Version 18.2.0

faraonc commented 5 years ago

It seems like this is a dependency https://www.npmjs.com/package/google-protobuf

jonny-improbable commented 5 years ago

Thanks for raising @faraonc, fixed in #161.