在 react-native 项目中包含 paypal-rest-sdk 会产生错误
Including paypal-rest-sdk in react-native project produces an error
当我导入 Paypal-Rest-SDK 并尝试 运行:
react-native run-android
发生错误:
"undefined is not a function(evaluating 'r(d[9]).configure')"
在出现这个错误之前,我删除了node_modules
文件夹并重新安装了所有模块,因为我和"evaluating 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>
);
}
}
希望有人能帮助我。我已经为这个问题搜索了将近一整天。
更新:
问题不是包含 paypal-rest-sdk,而是当我尝试配置 paypal 变量时的下一行。当我将它们注释掉时,错误消失了......但据我所知,有必要配置
更新 2
运行 之后
npm 安装 --save paypal-rest-sdk
我回到问题
undefined is not an object (evaluating 'process.versions.openssl')
您正在使用 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
当我导入 Paypal-Rest-SDK 并尝试 运行:
react-native run-android
发生错误:
"undefined is not a function(evaluating 'r(d[9]).configure')"
在出现这个错误之前,我删除了node_modules
文件夹并重新安装了所有模块,因为我和"evaluating 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>
);
}
}
希望有人能帮助我。我已经为这个问题搜索了将近一整天。
更新: 问题不是包含 paypal-rest-sdk,而是当我尝试配置 paypal 变量时的下一行。当我将它们注释掉时,错误消失了......但据我所知,有必要配置
更新 2 运行 之后 npm 安装 --save paypal-rest-sdk 我回到问题
undefined is not an object (evaluating 'process.versions.openssl')
您正在使用 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