Dar*_*991 5 javascript node.js reactjs react-native
我只是尝试将一些节点模块添加到react-native中。我发现它只能与反应本机模块和react-native link该模块一起使用。
我想使用: - https://www.npmjs.com/package/node-google-image-search 或 - https://www.npmjs.com/package/first-image-search-load
当我使用带有“非反应模块”的命令链接时,我仍然什么也得不到:

另外,当我试图通过以下方式添加此模块时:
import 'first-image-search-load'import {saveFirstImage} from 'first-image-search-load'import * from 'first-image-search-load'var first-image-search-load = require('first-image-search-load');var first-image-search-load = require('./first-image-search-load');var first-image-search-load = require('./node-modules/first-image-search-load');并尝试将它们放入 index.android.js 我得到:

开发服务器返回响应错误码:500
网址: http ://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false
正文:{“message”:“无法解析来自 /Users/Pien/Projects/smog_bielsko/node_modules/node-google-image-search/index.js 的模块 https:模块映射或这些目录中不存在模块: \n /Users/Pien/Projects/smog_bielsko/node_modules/node-google-image-search/node_modules\n、/Users/Pien/Projects/smog_bielsko/node_modules\n\n这可能与https://github.com相关/facebook/react-native/issues/4968 \n要解决此问题,请尝试以下操作:\n 1. 清除守望者手表:
watchman watch-del-all.\n 2. 删除node_modules文件夹:rm -rf node_modules && npm install.\n 3. 重置打包器缓存:rm -fr $TMPDIR/react-*或npm start -- --reset-cache.","name" :"UnableToResolveError","type":"UnableToResolveError","errors":[{}]} onResponse DevServerHelper.java:323 执行 RealCall.java:126 运行 NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1113 运行 ThreadPoolExecutor.java :588 运行 Thread.java:818
请告诉我如何将普通的 npm 插件导入到 React-Native 中。
谢谢
您不需要链接不使用本机代码的包。对于只有 js 的库,你需要做的就是npm install packageName. 如果库有任何 html/css/dom 内容,那么它将无法与 React Native 一起使用。
| 归档时间: |
|
| 查看次数: |
13457 次 |
| 最近记录: |