I'm trying to get protobuf to run in typescript.
The official Google Documentation says to simply use npm install google-protobuf and then to require('google-protobuf').
I'm unexperienced with npm, so I ran into several problems there. First of all, require('google-protobuf') returned an error 404, because the file was not found. I instead opted to require the file manually, so I sourced it in my index.html:
<script src="node_modules/google-protobuf/google-protobuf.js"></script>
This should work right?
What instead happens is that I get an Uncaught reference error: exports is not defined. How do I even begin to debug this? I tried to take a look at the google-protobuf.js file and found a few exports statements, but I don't know what I'm expected to do here.
If it helps at all, here is my tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}