2

I have this error when I write

npm start

command in VSCode Terminal:

Error: Could not find a production build in the 'E:\React-Practis\nextjs-project2.next' directory. Try building your app with 'next build' before starting the production server."

How can I resolve this error?

jps
  • 20,041
  • 15
  • 75
  • 79
  • Please share what's written in scripts of package.json for npm start – Servesh Chaturvedi Sep 04 '22 at 14:15
  • 2
    You have to execute `npm run build` before executing `npm run start`, because `npm run start` will execute the build output inside `.next` folder. If you want to run in development environment, you may want to try `npm run dev` instead. – dave.tdv Sep 04 '22 at 14:19
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 04 '22 at 22:18
  • Does this answer your question: [What's the difference between npm run dev and npm run start in Next.js?](https://stackoverflow.com/questions/69400243/whats-the-difference-between-npm-run-dev-and-npm-run-start-in-next-js)? – juliomalves Sep 05 '22 at 22:02

1 Answers1

1

Try this:

npm run build

Then do this:

npm run start
Wayne Celestin
  • 149
  • 1
  • 6