简体   繁体   中英

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".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM