gpt4 book ai didi

javascript - react-native 中的 Node 模块

转载 作者:行者123 更新时间:2023-11-29 21:08:34 24 4
gpt4 key购买 nike

我只是尝试将一些 Node 模块添加到 react-native 中。我发现它只适用于 react-native modulesreact-native link 该模块。

我想使用:- https://www.npmjs.com/package/node-google-image-search或者- https://www.npmjs.com/package/first-image-search-load

我试过: Link1 Link2 Link3 Link4

当我将命令链接与“非 react 模块”一起使用时,我仍然一无所获: enter image description here

此外,当我试图通过以下方式添加此模块时:

  1. import 'first-image-search-load'
  2. 从“first-image-search-load”导入 {saveFirstImage}
  3. 从 'first-image-search-load' 导入 *
  4. var first-image-search-load = require('first-image-search-load');
  5. var first-image-search-load = require('./first-image-search-load');
  6. var first-image-search-load = require('./node-modules/first-image-search-load');

然后尝试将它们放入 index.android.js 我得到: enter image description here

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

Body: {"message":"Unable to resolve module https from /Users/Pien/Projects/smog_bielsko/node_modules/node-google-image-search/index.js: Module does not exist in the module map or in these directories:\n /Users/Pien/Projects/smog_bielsko/node_modules/node-google-image-search/node_modules\n, /Users/Pien/Projects/smog_bielsko/node_modules\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman
watch-del-all
.\n 2. Delete the node_modules folder: rm -rf
node_modules && npm install
.\n 3. Reset packager cache: rm -fr
$TMPDIR/react-*
or npm start --
--reset-cache
.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]} onResponse DevServerHelper.java:323 execute RealCall.java:126 run NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1113 run ThreadPoolExecutor.java:588 run Thread.java:818

请告诉我如何将普通的 npm 插件导入 react-native..

谢谢

最佳答案

实际上,ReactNativify项目应该做到这一点,让我们在 React-Native 代码项目 (RN) 中使用 NodeJS 模块。

在我撰写本文时,2017 年 5 月,project seems to not work with RN versions 0.43.3+, due to breaking changes .

关于javascript - react-native 中的 Node 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42768221/

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