hermes: Invalid Statement encountered. js enginer: hermes

Bug Description

ERROR    SyntaxError: 4:1:invalid statement encountered., js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
  • I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.5.2-rc1 React Native version (if any): 0.63.4 OS version (if any): * but currently testing on Catalina 10.15.7 Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64

Steps To Reproduce

  1. This code resides in a monorepo orchestrated with Lerna so it could be part of the issue
  2. Mobile codebase resides at ./consumer-mobile/mobile/
  3. change build.gradle file as follows:
    if (enableHermes) {
        def hermesPath = "../../../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

and

project.ext.react = [
    entryFile: "mobile/consumer-mobile/index.js",
    root: "../../../../",
    enableHermes: true,  // clean and rebuild if changing,
    hermesCommand: "../../../../node_modules/hermes-engine/%OS-BIN%/hermesc",
]

and

def enableHermes = project.ext.react.get("enableHermes", true);

The Expected Behavior

App compiles and builds with Hermes engine

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I am also facing the same issue when using template function of lodash which is calling new Function() method in hermes, is there any other method which we can use instead of template function.

I am facing a similar issue with hermes enabled. Have a look at following:

console.log(eval((1+1))) --> This Works console.log(eval(‘(class abc{})’)) --> This throws error invalid expression at 1:2

If I disable Hermes, both of them executes fine.

Closing, since no actionable information has been provided. Hermes does not yet support “local eval”, though support has been planned for a future version.