在反应性应用程序中使用pusher npm

时间:2016-01-22 21:46:44

标签: react-native

我试图通过聊天功能获得基本的反应性应用。在https://www.npmjs.com/package/pusher

上找到了推动者npm

使用以下方法将模块安装到项目中:

npm install pusher --save

一旦我按照代码行添加了反应组件

var Pusher = require('pusher');

xcode项目停止使用以下堆栈跟踪进行编译:

bundle: Created ReactPackager
uncaught error Error: UnableToResolveError: Unable to resolve module crypto from /Users/dmitry/hacks/tentags/TenTags/node_modules/request/lib/helpers.js: Invalid directory /Users/node_modules/crypto
    at ResolutionRequest.js:356:15
    at tryCallOne (/Users/dmitry/hacks/tentags/TenTags/node_modules/promise/lib/core.js:37:12)
    at /Users/dmitry/hacks/tentags/TenTags/node_modules/promise/lib/core.js:123:15
    at flush (/Users/dmitry/hacks/tentags/TenTags/node_modules/asap/raw.js:50:29)
    at nextTickCallbackWith0Args (node.js:452:9)
    at process._tickCallback (node.js:381:13)
See logs /var/folders/gq/zxnwqjwd75d_2rhgbzzc_0n00000gn/T/react-packager.log
    at SocketClient._handleMessage (SocketClient.js:139:23)
    at BunserBuf.<anonymous> (SocketClient.js:53:42)
    at emitOne (events.js:77:13)
    at BunserBuf.emit (events.js:169:7)
    at BunserBuf.process (/Users/dmitry/hacks/tentags/TenTags/node_modules/bser/index.js:289:10)
    at /Users/dmitry/hacks/tentags/TenTags/node_modules/bser/index.js:244:12
    at nextTickCallbackWith0Args (node.js:452:9)
    at process._tickCallback (node.js:381:13)
Command /bin/sh failed with exit code 1

我做错了什么?推送器npm只适用于react.js网络应用吗?在ractnative应用程序中,我不能使用推送器npm吗?我知道,也许天真的问题,但我对于反应性和整个JS,Node,npm业务都是新手。

1 个答案:

答案 0 :(得分:0)

安装时请检查您是否在react的目录中。确保已加密,也尝试安装pusher-js ...并使用react-native

import Pusher from 'pusher-js/react-native';