当我导入Paypal-Rest-SDK并尝试运行时:
react-native run-android
发生错误:
"undefined is not a function(evaluating 'r(d[9]).configure')"
在发生此错误之前,我删除了node_modules
文件夹并重新安装了所有模块,因为我在“评估process.versions.openssl”时遇到了类似的错误。当我致电node -p process.versions
时,将显示以下内容:
{ http_parser: '2.8.0',
node: '8.12.0',
v8: '6.2.414.66',
uv: '1.19.2',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
nghttp2: '1.32.0',
napi: '3',
openssl: '1.0.2p',
icu: '60.1',
unicode: '10.0',
cldr: '32.0',
tz: '2017c' }
以下是我使用Paypal-sdk的代码:
'use strict';
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, TouchableHighlight, Linking} from 'react-native';
var paypal = require('paypal-rest-sdk');
paypal.configure({
mode: 'sandbox', // Sandbox or live
client_id: 'x',
client_secret: 'y'});
export default class Paypal extends Component{
constructor(props)
{
super(props);
console.log(process);
}
render()
{
return(
<View>
<Text>This is gonna be a PayPal Thing</Text>
</View>
);
}
}
我希望有人能帮助我。对于这一问题,我几乎整天都在Google搜索。
更新: 问题不是paypal-rest-sdk的内容,而是我尝试配置paypal变量时的下一行。当我将其注释掉时,该错误消失了……但是据我所知有必要对其进行配置
更新2号 跑步后 npm install-保存paypal-rest-sdk 我回到问题了
undefined is not an object (evaluating 'process.versions.openssl')
答案 0 :(得分:0)
您正在使用paypal-rest-sdk
,它是NodeJS PayPal SDK,我相信它与React Native不兼容。我建议尝试一些类似React Native的东西
https://www.npmjs.com/package/react-native-paypal-wrapper
https://www.npmjs.com/package/react-native-paypal
或使用普通的PayPal rest API https://developer.paypal.com/docs/api/overview/#api-requests