Ray
Ray

Reputation: 1728

Next Start not working - Cant find index.js and throwing cannot find module error

I have a nextjs project that I originally started with npx create-next-app --typescript a while back.

next version: 10.0.4

In package.json file:

  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
  },

Im able to use npm run dev to access my project. Im also able to use npm run build to create the build version of my project.

However, when I try to use npm run start or npm start, I keep getting the following error:

Error: Cannot find module 'D:\myProject\.next\server\pages\index.js'

When I look in the .next directory, I dont see an index.js file but a index.html file.

Ive tried this with a brand new nextjs project and went through the same steps using their boiler plate app (npx create-next-app --typescript) and when generating a build version, it didnt have an index.js file either but when using npm start, it worked.

Anyone come across this issue? Is it the version of Next? When I tried the boiler plate app method, it uses "next": "11.1.0". My full project uses "next": "^10.0.4".

Upvotes: 2

Views: 8927

Answers (1)

Ray
Ray

Reputation: 1728

Found an answer if anyone encounters the same issue. I had to basically updated my react, reactDom and next to its latest versions. Once all were updated, npm start or next start worked.

I followed the steps here.

https://nextjs.org/docs/upgrading

Upvotes: 2

Related Questions