skip to Main Content

Starting a nextjs project, after running npx create-next-app@latest trying to start the project with npm run dev but failing. I’ve spent time reading relevant posts and have attempted all methods. Eg) full wipe of node/nvm from OS, using NVM.
Getting this during the build: wrong node version

Spun up a new vite app and opened some previous next.js projects without issue.

  • Full node wipe, and install from website dl to 20.10.0 so i don’t see why it’s pointing to v16.14.2 for some reason. I’ve tried using NVM to uninstall all other versions and set the default as well, still the same error as above. npx and npm both in the /bin appropriately.

  • Trying npm i node @lts within the project as suggested throws this: enter image description here

  • Tried removing next folder, node_modules and cache clean with full reinstall of packages (did not do canary install yet) in this post text

Any suggestions on why it’s trying to default to this version that I no longer have on my machine, or how to fix?

2

Answers


  1. Chosen as BEST ANSWER

    Unclear on the causation, but node dependency not added to package.json, when using auto or manual Next.js install methodologies from terminal. Solved by manually adding Node dependency to package.json file of project.


  2. go to the terminal and type

    node -version //This will give you the current node version, in your case update version 
    

    then go to the next js project and find package.json file. Here you need to replace the old node version with the current node version

    "node": ">=20.10.0"
      
    

    Delete the node_modules and package-lock.json files then go to the terminal and reinstall dependencies

    npm install 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search