Home > OS >  Updating Node.js doesn't seem to work, I still get the old version
Updating Node.js doesn't seem to work, I still get the old version

Time:01-20

I want to run create react app. I run the command:

npx create-react-app client

but I get this error:

You are running Node 10.9.0. Create React App requires Node 14 or higher. Please update your version of Node.

I updated it with latest version and using node -v it is showing version v18.13.0. But after that I'm still getting same error.

How do I solve the problem?

CodePudding user response:

Things to try when this sort of thing happens:

  • If you haven't already, close the command prompt / terminal window where you're running this and open a new one.

  • If that doesn't work, completely reboot (mostly a Windows thing).

  • If that doesn't work, completely uninstall Node.js, reboot (mostly a Windows thing), and then install the latest.

Usually if the first two don't solve the problem, the last will.

CodePudding user response:

You can manually define which Node engine to use for your project in package.json file.

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": ">=18"
  },
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.2.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
  • Related