我使用react-native来开发Android应用程序。当应用程序运行时,我尝试从react-native开发人员菜单中选择Debug in Chrome
,然后它应用程序崩溃,但在控制台中,我运行命令react-native start
我看到并错误:
Launching Dev Tools...
ERROR Wrong length!
RangeError: Wrong length!
at validateArrayBufferArguments (/Users/sergiigetman/IdeaProjects/mbc_kidsvod_client/node_modules/babel-polyfill/node_modules/core-js/modules/_typed-buffer.js:157:39)
at new ArrayBuffer (/Users/sergiigetman/IdeaProjects/mbc_kidsvod_client/node_modules/babel-polyfill/node_modules/core-js/modules/_typed-buffer.js:247:29)
at createUnsafeArrayBuffer (buffer.js:43:12)
at createUnsafeBuffer (buffer.js:37:25)
at allocate (buffer.js:199:12)
at Function.Buffer.allocUnsafe (buffer.js:162:10)
at new Buffer (buffer.js:93:19)
at BufferPool.reset (/Users/sergiigetman/IdeaProjects/mbc_kidsvod_client/node_modules/ws/lib/BufferPool.js:57:26)
at Receiver.endPacket (/Users/sergiigetman/IdeaProjects/mbc_kidsvod_client/node_modules/ws/lib/Receiver.js:247:68)
at Receiver.finish (/Users/sergiigetman/IdeaProjects/mbc_kidsvod_client/node_modules/ws/lib/Receiver.js:483:12)
Haven在堆栈和互联网上没有发现任何类似的问题。
答案 0 :(得分:1)
我已经能够重现这个错误,并且它似乎是一个边缘情况,因为使用babel-polyfill版本6.16.0运行旧版本的React Native(0.22.x)。当前版本的React Native(0.40.0)和Babel Polyfill(6.20.0)不会出现此错误。我们认为它不相关,但我们正在运行节点7.2.0。
如果您无法更新您的环境,一个临时解决方法是编辑&#babel-polyfill / node_modules / core-js / modules / _typed-buffer.js'并修改该文件的第157和175行的缓冲区检查:
if(numberLength != byteLength)throw RangeError(WRONG_LENGTH);
如果您正在运行babel-polyfill 6.20.0,那么您的文件将在此处:
node_modules/core-js/modules/_typed-buffer.js
我们已经能够通过评论这个长度检查来让我们的开发环境工作,但需要注意,你可能不想让它投入生产。