Search code examples
javascriptreactjsvitegit-bash

Error message on terminal when trying to create a React project


Im currently doing the Odin Project for web development (javascript path). In the React Course, im learning to set up a project with React. This is the page: https://www.theodinproject.com/lessons/node-path-react-new-setting-up-a-react-environment

The problem is that when I paste the command npm create vite@latest my-first-react-app -- --template reactinto the CLI, I get an error.

The error is:

npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: C:\Users\equipo\AppData\Local\npm-cache\_logs\2024-08-09T19_54_01_302Z-debug-0.log

Im using git Bash, and my pc can't run a virtual machine or WSL2... so I m stuck with this.

Anyone could help me? Thanks!!

PS: node and npm are up to date.

I really don't know what to do, I search on google and stack overflow posts but couldn't find the solution... and in the Odin Porject they dont help windows users...


Solution

  • node and npm are up to date.

    When you say up to date, do you mean LTS(v20.16.0) or Current(v22.6.0)? If you are on current, consider changing to LTS (Long-Term-Support) version, it tends to be more stable. Either:

    • Download node LTS installer and installer should prompt you to remove previously installed node version before installing new one.
    • Use windows-nvm (Download nvm-setup.zip file that contains nvm installer) to install multiple versions of node (and npm) and test, if LTS version can solve your problem.

    Also check out this answer on similar Stack Overflow thread.


    P.S. I couldn't replicate the issue myself, but linked Stack Overflow answer or switching node versions should do the trick. Hope this helps :)

    P.P.S. Sorry for posting this as an answer, I don't have enough reputation to add this as a comment to your post.