Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Realm js和Node.js:登录到Realm对象服务器时出现异常_Javascript_Node.js_Realm - Fatal编程技术网

Javascript Realm js和Node.js:登录到Realm对象服务器时出现异常

Javascript Realm js和Node.js:登录到Realm对象服务器时出现异常,javascript,node.js,realm,Javascript,Node.js,Realm,我将继续我的领域js测试。我编写了一个小测试来检查与服务器的同步: 'use strict'; var Realm = require('realm'); const SmsSchema = { phone: 'string', msg: 'string', uuid: 'string', status: 'int' }; var realm; Realm.Sync.User.login('http://xx.xxx.xxx.xx:9080','login'

我将继续我的领域js测试。我编写了一个小测试来检查与服务器的同步:

'use strict';

var Realm = require('realm');

const SmsSchema = {
    phone: 'string',
    msg: 'string',
    uuid: 'string',
    status: 'int'
};

var realm;
Realm.Sync.User.login('http://xx.xxx.xxx.xx:9080','login','password', (error, user) => {
    if (!error) {
        realm = new Realm({
            sync: {
                user: user,
                url: 'realm://xx.xxx.xxx.xx:9080/~/SMSService',
            },
            schema: [SmsSchema]
        });
    }
    else
        console.log('Connection error!');
});


realm.close();
测试开始后,我发现以下异常:

Realm.Sync.User.login('http://xx.xxx.xxx.xx:9080','login','password', (error, user) => {
      ^

TypeError: Cannot read property 'User' of undefined
at Object.<anonymous> (/home/hermann/WebstormProjects/SMSService/app.js:15:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

有人能帮我解决这个错误吗?我必须补充一点,我以前从未见过Node.js,我上一次使用JavaScript的经历是在一年多以前……

问题是,realm js中Linux的同步API仅适用于realm Mobile Platform的专业/企业版。你必须报名参加免费试用。NPM上的公共免费版本不包括Linux对同步的支持。

我可以再问你一个问题吗?我安装了RealmJS的试用版,但在登录过程中出现以下错误:错误:“name”的类型必须为:string。我不明白这个变量“name”在哪里?在登录过程中是否传递了字符串以外的内容作为用户名?不,我传递的内容与上面的代码完全相同。当然是真正的IP,登录和密码。可能是因为真实姓名是电子邮件地址'smsuser@mail.ru“?是的,原因似乎是用户名错误,如果Realm Server在注册期间接受电子邮件地址作为用户名,我该怎么办?@EpicPandaForce是的,同步在React Native上可用。”