尝试使用面向语法错误的节点运行ripple-lib

时间:2018-03-22 18:55:47

标签: node.js

尝试使用ripple-lib运行rippleApi,以解决语法错误等问题。 我是Node和ripple-lib的新手。请指导我摆脱这个。提前致谢

node ripple.js

ripple.js中的我的代码是

const RippleAPI = require('ripple-lib').RippleAPI;

const Ripple = new RippleAPI({
server: 'wss://s1.ripple.com:443'
});

Ripple.on('error', function (errorCode, errorMessage) {
resp.json('{"status":0,"msg":"Unable to withdraw, problem occured. '+errorMessage+'."}');
});

Ripple.on('connected', function () {
});
Ripple.on('disconnected', function (code) {
console.log('disconnected, code:', code);
});
Ripple.connect().then(function () {
return Ripple.getServerInfo();
}).then(function (server_info) {

var rippleAddress = Ripple.generateAddress();

console.log(rippleAddress);process.exit(-1);

}).catch(console.error);

输出结果是

/var/www/html/node_modules/ripple-lib/dist/npm/api.js:83
    constructor(options = {}) {
                        ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/var/www/html/node_modules/ripple-lib/dist/npm/index.js:3:13)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

1 个答案:

答案 0 :(得分:0)

您需要升级nodejs

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs