Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restricted in strict mode, js engine: hermes #34868

Closed
tapz opened this issue Oct 4, 2022 · 8 comments
Closed

Restricted in strict mode, js engine: hermes #34868

tapz opened this issue Oct 4, 2022 · 8 comments

Comments

@tapz
Copy link

tapz commented Oct 4, 2022

Description

After updating to RN 0.70.2 I started getting this error:

Error: Requiring module "src/api/Api.js", which threw an exception: TypeError: Restricted in strict mode, js engine: hermes

Version

0.70.2

Output of npx react-native info

System:
OS: macOS 12.6
CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 73.93 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - /usr/local/opt/node@16/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.15.0 - /usr/local/opt/node@16/bin/npm
Watchman: 2022.10.03.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK:
API Levels: 25, 26, 27, 28, 29, 30, 31, 33
Build Tools: 30.0.3, 31.0.0, 33.0.0
Android NDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: 14.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.70.2 => 0.70.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Import a function.

Snack, code example, screenshot, or link to a repository

import { logout } from './api/Api';

@hikmert
Copy link

hikmert commented Oct 5, 2022

Same issue here

@tapz
Copy link
Author

tapz commented Oct 5, 2022

@hikmert This is because of Axios 1.0.0.

axios/axios#4998 (comment)

@denialfarizi1
Copy link

downgrade axios to axios ^0.27.2
and
npm start -- --reset-cache

@slasho
Copy link

slasho commented Nov 10, 2022

so the problem is axios not hermes or react-native?

@Namdurash
Copy link

I faced the same issue. After reading the tips above, I downgraded my axios to version 0.27.2 and launched the bundler with the --reset-cache flag. It really helped. Apparently, axios uses inside some part of the code that is prohibited in Hermes, which makes it undesirable to use axios until it is fixed. Because downgrading to such a low version is extremely dangerous in production.
Steps to resolve it:

  1. yarn upgrade axios@^0.27.2
  2. yarn start --reset-cache

@sujathasperi2022
Copy link

has the same issue the above fix helped it.

@guilhermecampossilva9
Copy link

I'm downgraded Axios 1.1.3 to 0.19.2 and works for me.

"axios": "0.19.2"

"react-native": 0.70.6

@RafaelJesus22
Copy link

Downgrading Axios from ^1.1.3 to ^0.27.2 worked fine for me

"react-native": "0.70.6"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants