gpt4 book ai didi

React-Native:找不到变量:缓冲区

转载 作者:行者123 更新时间:2023-12-03 23:08:23 49 4
gpt4 key购买 nike

我对变量 Buffer 有疑问。您可以在下图中看到它。
有谁能够帮助我???

Error

谢谢。

最佳答案

所以 buffer 是 Node JS 的核心模块,这意味着它可能是与 Node JS 二进制文件捆绑在一起的 C++ 代码,而不是 Javascript。 React Native 打包器无法将它与您应用的 Javascript 包一起打包,因此您会收到运行时错误:无法解析模块。

要解决此问题,您需要执行此操作以使其在 react-native 中运行

npm i --save react-native-randombytes
react-native link react-native-randombytes

# install latest rn-nodeify
npm i --save-dev tradle/rn-nodeify

# install node core shims and recursively hack package.json files

Now you need to run this command in your project directory

./node_modules/.bin/rn-nodeify --hack --install

最后一步

在你的 app.js 中导入这个
import './shim.js'

在 packaje.json
把这个 postinstall:./node_modules/.bin/rn-nodeify --hack --install

关于React-Native:找不到变量:缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60788243/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com