为什么decodeIO 的 protobufjs 在 拖到creator里面直接报错

Compile error: Cannot require ‘1’ from ‘/Users/momo/Documents/HelloWorld/temp/scripts/assets/Script/Frame’. Module not found.
at Readable. (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/page/compile-worker.js:1:3554)
at emitOne (events.js:96:13)
at Readable.emit (events.js:188:7)
at Labeled. (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/read-only-stream/index.js:28:44)
at emitOne (events.js:96:13)
at Labeled.emit (events.js:188:7)
at Labeled. (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/stream-splicer/index.js:130:18)
at emitOne (events.js:101:20)
at Labeled.emit (events.js:188:7)
at Deps. (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/stream-splicer/index.js:130:18)
at /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/compiler.js:1:1022
at /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/compiler.js:1:466
at BrowserWindow. (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/compiler.js:1:2045)
at BrowserWindow.g (events.js:286:16)
at emitOne (events.js:101:20)
at BrowserWindow.emit (events.js:188:7)

先保证你的 js 能在浏览器跑起来,然后导入为插件,具体参考 http://www.cocos.com/docs/creator/scripting/plugin-scripts.html

我用的helloworld工程测试,好的。我试一试

jare大
cat 后,导入为插件了。然后怎么用呢? require提示找不到这个模块,看文档里面说不能require,那要如何使用好萌比:joy:

一般都是会注册到 window 上的。比如你原来是 var io = require(‘protobuf’); 现在是 var io = window.decodeIO;

1赞

好的。谢谢。