jeudi 19 septembre 2019

'module.exports' not working with gRPC (npm-project)

I create protobuf files and grpc services with this command:

protoc -I=./src/proto $(find ./src/proto -iname *.proto) --js_out=import_style=commonjs:./src/grpc-generated --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./src/grpc-generated

JS-files are generated and at the end of each there is an export.

module.exports = proto.tech.lmru.auth.grpc.service.generated.impl;

I import like this:

const userServiceClient = require('../grpc-generated/AuthEntity_grpc_web_pb.js');

But browser catch exception:

TypeError: Cannot assign to read only property 'exports' of object '# <Object>'


What to do?




Aucun commentaire:

Enregistrer un commentaire