reactjsnext.js13nvmfish

Next.js error: "You are using Node.js 18.15.0. For Next.js, Node.js version >= 18.17.0 is required" despite using a higher Node.js version


I recently created a Next.js app using the CLI, and when I tried to run the development server with npm run dev, I encountered this error:

You are using Node.js 18.15.0. For Next.js, Node.js version >= 18.17.0 is required.

However, my actual Node.js version is 20.10.0, which is clearly higher than the required version.

Here’s what I’ve tried so far:

I’m not sure why Next.js is picking up an older version of Node.js. How do I fix this?


Solution

    1. Verify Node.js versions: Check available versions here to ensure you are using a compatible version for your Next.js project.

    2. Install and use the correct version with nvm: Using nvm allows you to switch between Node.js versions easily, ensuring compatibility with different projects. Run the following commands to install and use the correct version:

      nvm install 22.5.1
      nvm use 22.5.1
      
    3. Re-run your development server: After switching versions, run your project again:

      npm run dev
      

    sample image enter image description here