SyntaxError: The requested module 'react' is expected to be of type CommonJS
Declan Middleton

Declan Middleton @declanmidd

About: Whatever comes to mind

Location:
Auckland, NZ
Joined:
Jul 23, 2022

SyntaxError: The requested module 'react' is expected to be of type CommonJS

Publish Date: Aug 12 '22
5 4

I've had this issue countless times during the processes of running the dev environment

Downgrading the nodejs version to 12.22.0 removes the error.

Comments 4 total

  • JoelBonetR 🥇
    JoelBonetR 🥇Aug 12, 2022

    Noo don't do that! 😱 Running outdated versions is always harmful in a way or another check this

    Use always the latest LTS (Long Term Support) which is the production, stable version (this is applied to any software).

    Instead of getting the "latest" which at the time of writting that is the experimental 18.7.0, use the 16.16.0 LTS.

    You can use NVM (Node Version Manager) to handle that easily:

    nvm install --lts // installs the latest Node LTS version
    nvm ls // list installed versions of Node
    nvm use 16.16.0 // make that specific version the default one for your runtime

    Check it and come back to add some feedback and see if the latest LTS worked as well (it'll probably do) and add more information if it doesn't (dependencies, dev dependencies, OS...)

    Also you can add the tag #help

    Best regards

    • Declan Middleton
      Declan MiddletonAug 29, 2022

      Yes, I've agreed to these use cases, using this as an option because other packages still require 12.22.0

      Regards

      • JoelBonetR 🥇
        JoelBonetR 🥇Aug 30, 2022

        And why don't you update those packages as well? 😅

        Updating project dependencies is a recurring task (once a week, once a month...) to fix possible vulnerabilities and not something you do by fashion.

        • Declan Middleton
          Declan MiddletonOct 24, 2022

          Sorry for the "mis reply"

          Like I said before "I've agreed to these use cases". The known packages that I've been using require 12.22.0 node version for compatibility using their library. I don't agree with it, I have to integrate it otherwise.

Add comment