React native react本地链接在域上失败

React native react本地链接在域上失败,react-native,realm,React Native,Realm,我有react-native/react-native cli的下一个版本: react-native-cli: 2.0.1 react-native: 0.47.2 在安装了带有 npm install --save realm 我犯了个错误 下一部分已解决,留有余地,以防有助于解决整个问题

我有react-native/react-native cli的下一个版本:

react-native-cli: 2.0.1  
react-native: 0.47.2
在安装了带有

npm install --save realm
我犯了个错误

下一部分已解决,留有余地,以防有助于解决整个问题<已解决部分开始

如果我跑

react-native link

我得到一个错误:

pathToProjectHere/node_modules/metro-bundler/src/lib/Terminal.js:141
    this._nextStatusStr = util.format(format, ...args);
                                              ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Module._extensions..js (module.js:416:10)
    at Object.require.extensions.(anonymous function) [as .js] (pathToProjectHerenode_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (pathToProjectHere/node_modules/react-native/local-cli/server/runServer.js:18:18)
    at Module._compile (module.js:409:26)
pathToProjectHere/node_modules/metro bundler/src/lib/Terminal.js:141
这._nextStatusStr=util.format(format,…args);
^^^
SyntaxError:意外标记。。。
在exports.runInThisContext(vm.js:53:16)
在模块处编译(Module.js:373:25)
at Module._extensions..js(Module.js:416:10)
at Object.require.extensions.(匿名函数)[as.js](pathtprojectherenode_modules/babel register/lib/node.js:152:7)
在Module.load(Module.js:343:32)
在Function.Module.\u加载(Module.js:300:12)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)

在对象上。

我认为realm已经认识到了这个问题,并为它提供了手动替代方案

请查看他们为该问题向您提供的页面:并按照其步骤操作

但我建议首先看一看,他们在以下情况下采用了一种循序渐进的方式来处理这个问题:


react-native链接
或(类似于)
react-native安装域
失败

我正在编写这些步骤,但强烈建议阅读安装指南,以便随时更新

  • 将以下行添加到android/settings.gradle
  • 将编译行添加到android/app/build.gradle中的依赖项中:
  • MainApplication.java中添加导入并链接包:

  • import io.realm.react.RealmReactPackage;// 我最终发现了一个问题,我的问题是对RN和Expo缺乏了解。由于我的项目是使用create react native app创建的,所以我的项目最初是附加到expo上的。要使用Realm,我必须。

    添加完整的错误可能有助于更好地理解问题。@bennygenel,done
    react native install Realm
    在安装和链接方面做得很好。也许你应该试试看?@ArchNoob,似乎是一个更好的解决方案,而不是安装和使用npm。但是我收到了同样的错误:)酷,谢谢,但我已经检查过了,并且已经做过了。不走运yetbtw,在运行Expo的应用程序中的iOS设备上出现此错误现在这个问题似乎非常具体,但当我检查
    npm过时时
    我发现最新的react-native是
    react-native 0.48.4
    ,想要的是
    react-native 0.45.1
    。请参阅:。建议,我认为您应该尝试升级(0.48.4)/降级(0.45.1)
    react native
    版本,看看是否有帮助@弗拉达特科
    pathToProjectHere/node_modules/metro-bundler/src/lib/Terminal.js:141
        this._nextStatusStr = util.format(format, ...args);
                                                  ^^^
    
    SyntaxError: Unexpected token ...
        at exports.runInThisContext (vm.js:53:16)
        at Module._compile (module.js:373:25)
        at Module._extensions..js (module.js:416:10)
        at Object.require.extensions.(anonymous function) [as .js] (pathToProjectHerenode_modules/babel-register/lib/node.js:152:7)
        at Module.load (module.js:343:32)
        at Function.Module._load (module.js:300:12)
        at Module.require (module.js:353:17)
        at require (internal/module.js:12:17)
        at Object.<anonymous> (pathToProjectHere/node_modules/react-native/local-cli/server/runServer.js:18:18)
        at Module._compile (module.js:409:26)
    
    include ':realm'
    project(':realm').projectDir = new File(rootProject.projectDir,'../node_modules/realm/android')
    
    dependencies {
        compile project(':realm')
    }
    
    import io.realm.react.RealmReactPackage; //   <<====   add this import
    
    public class MainApplication extends Application implements ReactApplication {
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new RealmReactPackage() //   <<====    add this line
            );
        }
    }