The generated commonjs `*_pb.js` files don't work in Node.js environment
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, node.js
- 领域
- backend
调研方向
使用所示的 protoc 命令和 Node.js v16.13.0 重现该问题,然后检查第 16 行全局初始化附近生成的 *_pb.js 代码。比较 protobuf 3.19.1–3.19.4 版本的行为;当生成的 CommonJS 文件可以在 Node.js 中导入和使用且不会出现 window 错误时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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?
- Run
protoc --js_out=import_style=commonjs,binary:path/to/out/dir --proto_path=. *.proto - 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);
- 主要语言
- JavaScript
- 星标
- 471
- 派生
- 91
- 平均合并
- 3 小时 57 分钟
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
protocolbuffers/protobuf-javascript 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 5/5 一周以上 新手友好度 30/100
protocolbuffers/protobuf-javascript#248 · 1 条评论 · 13 个 reaction ·
-
question
难度 3/5 1-2 天 新手友好度 45/100
protocolbuffers/protobuf-javascript#222 · 9 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#185 · 1 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#182 · 3 条评论 · 1 个 reaction ·
查看 protocolbuffers/protobuf-javascript 的全部 Issue
相似的 Issue
-
Bug
难度 2/5 1-3 小时 新手友好度 70/100
Automattic/safe-publish#594 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
难度 2/5 1-3 小时 新手友好度 70/100
NousResearch/hermes-agent#121143 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
难度 2/5 1-3 小时 新手友好度 75/100