导入节点标准库模块“ crypto”时出错

时间:2020-07-06 04:25:33

标签: javascript node.js react-native node-modules cryptojs

当我尝试编译我的应用程序时,尽管我没有明确地尝试在自己编写的任何文件中导入加密,但仍收到附件错误。似乎已将其导入到node_modules文件夹中自动存在的文件中。有没有人熟悉给定的错误?error

The package at "node_modules\reques\lib\helpers.js" attempted to import the Node standard library module "crypto". It failed because the native React runtime does not include the Node standard library. Read more at https://docs.expo.io/introduction/faq/#can-i-use-nodejs-packages-with-expo

2 个答案:

答案 0 :(得分:0)

您不能使用请求包,它包含React Native不支持的原生Node.js库。使用为React本机创建的另一个请求库。

答案 1 :(得分:0)

这是因为您的本机项目中的依赖项正在使用加密库。

安装的依赖项之一不是为react-native创建的,而是要在服务器上运行的。找出哪个依赖项,然后可以将其更改为反应本地兼容库以解决该问题。

相关问题