所有节点模块都应该开箱即用吗?

时间:2015-04-17 07:19:46

标签: node.js react-native

我尝试使用npm install(特别是https://github.com/Thuzi/facebook-node-sdk/)使用一些带有react本机模块的节点模块,并且在运行应用程序时,我不断收到有关未解析的依赖项的错误。节点模块通常应该由本机响应或仅为其专门编写的模块(例如此https://github.com/brentvatne/react-native-login)支持。

1 个答案:

答案 0 :(得分:0)

Many Node modules will not work with React Native. Some of the reasons are architectural and can be fixed (ex: currently React Native supports only asynchronous native methods while Node supports synchronous ones as well), while others are inherent to the fact that Node runs on V8 and React Native iOS runs on JSC.

As a heuristic, you should find success with Node modules that are utilities and depend only on JavaScript's core library (the APIs defined here: https://people.mozilla.org/~jorendorff/es6-draft.html). This includes things like sorting algorithms, string formatting, etc.