Skip to content

The generated commonjs *_pb.js files don't work in Node.js environment #8

Description

@yevhenii-nadtochii

This bug is a rebirth of protocolbuffers/protobuf#9152, which has already been fixed in v3.19.1. It seems the fix hasn't been delivered to the latest version.

What version of protobuf and what language are you using?
Version: v3.20.1
Language: Javascript

What operating system (Linux, Windows, ...) and version?
macOs Monterey v12.3.1

What runtime / compiler are you using (e.g., python version or gcc version)
Node.js v16.13.0

What did you do?

  1. Run protoc --js_out=import_style=commonjs,binary:path/to/out/dir --proto_path=. *.proto
  2. Try to import and use the generated *_pb.js files.

What did you expect to see
Import and use without errors (just as in 3.19.1 - 3.19.4).

What did you see instead?

ReferenceError: window is not defined

   14 | var jspb = require('google-protobuf');
   15 | var goog = jspb;
 > 16 | var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions