Skip to content

Restricted in strict mode, js engine: hermes (React Native + Axios 1.0.0) #4998

Closed

Description

@tapz

Describe the bug

Getting an error with React Native when importing a function from a file, which uses Axios.

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

To Reproduce

Import a function.

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

---

export function logout() {
  return axios.put(endPoint, body, {
      headers: {
        ...Headers,
        ...headers
      }
    });
}

Expected behavior

No errors

Environment

  • Axios Version: 1.0.0
  • Node.js Version: 16
  • OS: MacOS
  • Additional Library Versions: React Native 0.70.2

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Activity

  1. changed the title [-]1.0.0: Restricted in strict mode, js engine: hermes[/-] [+]Restricted in strict mode, js engine: hermes (React Native + Axios 1.0.0)[/+] on Oct 4, 2022
  2. ManishBitsInfotech commented on Oct 5, 2022

    @ManishBitsInfotech

    i have the same issue in my new react native project please let me know if there is any solution for the same

  3. hikmert commented on Oct 5, 2022

    @hikmert

    It's same here with a new React-native project. It doesn't allow any JS files although I set allowJs to true in tsconfig.json

  4. ManishBitsInfotech commented on Oct 5, 2022

    @ManishBitsInfotech

    What is the solution for this

  5. uasad1099 commented on Oct 5, 2022

    @uasad1099

    lower axios version worked for me - axios:'0.26.0'

  6. grandevel commented on Oct 5, 2022

    @grandevel

    Same issue, 3 different RN projects with 1.0.0. All projects use axios interceptors in some form. Downgraded to 0.27.2, working fine again.

  7. ManishBitsInfotech commented on Oct 6, 2022

    @ManishBitsInfotech

    I have downgrade the axios version for this issue
    https://www.npmjs.com/package/axios/v/0.26.0

    and also add this line in my api call for use formData

    axios.post(url, formData, {
    headers: { 'Content-Type': 'multipart/form-data' },
    transformRequest: formData => formData, // this line
    })

    i hope this will work for you too guys

  8. hikmert commented on Oct 6, 2022

    @hikmert

    Downgrading Axios resolved the issue for me.

  9. jrobinsonadrenaline commented on Oct 6, 2022

    @jrobinsonadrenaline

    Same issue here, as well as the same solution - downgrade to v0.26.0

  10. am2619015 commented on Oct 7, 2022

    @am2619015

    Same issue here on axios 1.1.0, let's hope there's another solution to the downgrade

  11. am2619015 commented on Oct 8, 2022

    @am2619015

    Had this issue with axios 1.1.2 in react native and was able to resolve it by replacing

    import axios from 'axios' with const axios = require('axios').default;

    I just tried it, it didn't work for me, the same error message keeps popping up "TypeError: Restricted in strict mode, js engine: hermes" besides a new one "[TypeError: Cannot read property 'default' of undefined]"

    "axios": "^1.1.2",
    "react": "18.1.0",
    "react-native": "0.70.2",

  12. ManishBitsInfotech commented on Oct 8, 2022

    @ManishBitsInfotech
  13. am2619015 commented on Oct 8, 2022

    @am2619015

    i have posted the solution for same please check it out
    …
    On Sat, 8 Oct, 2022, 11:35 pm ANDRES MADERA, @.> wrote: Had this issue with axios 1.1.2 in react native and was able to resolve it by replacing import axios from 'axios' with const axios = require('axios').default; I just tried it, it didn't work for me, the same error message keeps popping up "TypeError: Restricted in strict mode, js engine: hermes" besides a new one "[TypeError: Cannot read property 'default' of undefined]" "axios": "^1.1.2", "react": "18.1.0", "react-native": "0.70.2", — Reply to this email directly, view it on GitHub <#4998 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3N4L33SDVYGELOFFS36TETWCGZXFANCNFSM6AAAAAAQ47XETY . You are receiving this because you commented.Message ID: @.>

    Yes downgrading axios to 0.26.0 works, I hope that in a future version of axios we will not have this problem

  14. iamciro commented on Oct 8, 2022

    @iamciro

    Same issue here, as mentioned by grandevel, downgrading to 0.27.2 solved it.

  15. tapz commented on Oct 9, 2022

    @tapz
    Author

    @ManishBitsInfotech Dowgrading is not a fix. It does not make 1.x.x work any better.

  16. 24 remaining items

  17. natemartins commented on Nov 4, 2022

    @natemartins

    While downgrading axios solves the issue, it is not recommended. What I did was to patch axios using @osielmesa PR.

    How to patch:

    1. Make the changes according to the PR.
    2. Install patch-package if you have not already done so.
    3. Run npx patch-package axios. Note that if you have not done Step 2, you will be prompted to install patch-package

    Hopefully, this resolves the issue for us while we await axios to fix it from their end or approve and merge the PR

  18. moustaouiSalaheddine commented on Nov 8, 2022

    @moustaouiSalaheddine

    Downgrading to Axios 0.27.2 resolved the issue for me.

    "axios": "0.27.2"

  19. Uzef1997 commented on Nov 9, 2022

    @Uzef1997

    Still getting the same issue in 1.1.3 version of axios any leads on that except downgrading the version

  20. Simba-Mupfunya commented on Nov 9, 2022

    @Simba-Mupfunya

    We are all waiting for the next release as it seems to be fixed in #5224. Only sure way for now unit then is to downgrade to 0.27.2, I saw somebody mention a patch but best to keep an eye on the releases

  21. thiago-albuquerque commented on Nov 9, 2022

    @thiago-albuquerque

    npm uninstall axios => npm install [email protected] => uninstall your app and then re-install.

  22. jasonsaayman commented on Nov 10, 2022

    @jasonsaayman
    Member

    Hi 👋

    Please try the latest pre-release by running the following:

    Please provide feedback in either the pinned issue or discussion thread 🧵

  23. 0xbenon commented on Nov 10, 2022

    @0xbenon

    Hi 👋

    Please try the latest pre-release by running the following:

    Please provide feedback in either the pinned issue or discussion thread 🧵

    Hi bro, i just installed this version, it works !

  24. krendus commented on Nov 13, 2022

    @krendus

    Hi wave

    Please try the latest pre-release by running the following:

    Please provide feedback in either the pinned issue or discussion thread thread

    this worked for me too thanks

  25. nelsonVE commented on Nov 14, 2022

    @nelsonVE

    Works like a charm, thank you

  26. jrobinsonadrenaline commented on Nov 14, 2022

    @jrobinsonadrenaline

    Hi 👋

    Please try the latest pre-release by running the following:

    Please provide feedback in either the pinned issue or discussion thread 🧵

    Works perfect for me! Thanks!

  27. bombillazo commented on Nov 15, 2022

    @bombillazo

    Seems this is still causing issues with React Native : react/react-native#34688

    UPDATE

    This fixed it for me.

  28. DigitalBrainJS commented on Nov 15, 2022

    @DigitalBrainJS
    Collaborator

    @bombillazo There doesn't seem to be anything related to Axios v1.2.0-alpha.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions