Search code examples
node.jsreactjsnpmvisual-studio-codecreate-react-app

`npx create-react-app` says it requires "Node 14 or higher" but I'm running 17.4.0. How can I fix this?


I'm trying to start a new React project on my Mac (running Mojave 10.14.5).

In VS Code's Terminal I ran npx create-react-app my-app and got a message saying that my version of Node was out of date. I updated node to version 17.4.0 and ran it again - still got the same message.

I then ran clear cache: npm cache clean --force and tried again - still no luck.

node -v says I'm running 17.4.0.

Would anyone know what I could do?


Solution

  • The first thing you need to do is to uninstall the create-react-app and then npm install it again. You can use these commands for uninstalling the create-react-app: if you are using NPM:

    npm uninstall -g create-react-app
    

    if you are using Yarn:

    yarn global remove create-react-app
    

    for creating new app you can use the following command:

    npx create-react-app@latest your-project-name
    

    You must notice that the create-react-app should not be installed globally as it is documented in Create-React-app Docs.

    Also please note that it is safe to say, always use the LTS version of node (that is 16.13.2 at this time).

    It should solve your problem with initiating a new react app.