【发布时间】:2017-08-03 17:45:35
【问题描述】:
我刚刚尝试将一些节点模块添加到 react-native 中。
我发现它只适用于 react-native modules 和 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
Body: {"message":"无法解析模块 https 来自 /Users/Pien/Projects/smog_bielsko/node_modules/node-google-image-search/index.js: 模块映射或这些目录中不存在模块:\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相关@\nTo 解决尝试以下方法:\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":[{}]} 响应 DevServerHelper.java:323 执行 RealCall.java:126 运行 NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1113 运行 ThreadPoolExecutor.java:588 运行 线程.java:818
请告诉我如何将普通的 npm 插件导入 react-native..
谢谢
【问题讨论】:
-
请发布文字,而不是图片。
标签: javascript node.js reactjs react-native react-native-android