最近在移植cocos2.0的代码到3.0 移植到net部分的时候环境都是好的但是就显示protobuf is not defined
1.我按照网上的方法npm i protobuf 安装pb module包 然后安装了 pbjs 与 pbts 重新生成了 js和d.ts文件
2.编辑器下方输出protobuf is not defined 在js的proto文件中把引入代码改为 require var $protobuf = require("protobufjs"); 编辑器报错问题不再出现
3.但是我在运行的时候,依旧在vscode调试控制台中显示protobuf is not defined,最终找到是因为我在引用这个proto文件的httpClass类中直接使用export default new httpClass() 我猜测由于代码在运行的时候还没有加载node_module 导致找不到protobuf