javascriptreact-nativereact-native-hermes

TypeError: Object.defineProperty is not a function


When I try to run my react native expo app in iOS using npm start , I get the following error in the require.js file:
the screenshot of the exception

I tried removing and readding the node_modules folder , but it didn't work. Thanks.

I also get the following errors together with this error. I don't know if they are related.

 ERROR  TypeError: Object.defineProperty is not a function (it is undefined), js engine: hermes
 ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

Solution

  • I solved the problem via tracing the "Call Stack" in the error screen in the simulator. It shows what scripts produce the problem.

    My problem was related to an import. Yours can be different but don't forget to look at the "Call Stack" in the error screen of your simulator.