I start my project, and so far so good.
npm run start
> [email protected] start
> next start
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from /Users/...../market/.env.local
warn - You have enabled experimental feature (appDir) in next.config.js.
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
But after this no more console output, not when making requests and not saving changes in my files, it will, however, output server side console.logs()
.
The page works in my browser (at localhost:3000
). But when I save changes (let’s say add a <h1>Hello</h1>
) I don’t get auto re-compilation. And npm run start
doesn’t make any changes either. The only way to get my newly saved changes is to run npm run build
followed by npm run start
This has happened to me in the past, the only way for me to get it working again was to start a completely new project. But I have gotten a little too far for that now.
I’ve googled like crazy, but the only thing I could find being somewhat closely related was about capital letters in the naming of my pages in my app folder, but that’s not the case here.
Also, I just created a brand new project with npm create-next-app
, but the same thing is happening. When running npm run start
I get:
Error: Could not find a production build in the '/Users/erikingman/MK/mk-test/.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
at NextNodeServer.getBuildId (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/next-server.js:352:23)
at new Server (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/base-server.js:146:29)
at new NextNodeServer (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/next-server.js:166:9)
at NextServer.createServer (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/next.js:167:24)
at async /Users/erikingman/MK/mk-test/node_modules/next/dist/server/next.js:187:31
at async NextServer.prepare (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/next.js:149:24)
at async Server.<anonymous> (/Users/erikingman/MK/mk-test/node_modules/next/dist/server/lib/render-server.js:109:17) {
type: 'Error'
}
I have to run npm run build
before I can run it, I have no recollection of doing that for new projects in the past.
2
Answers
You are not using the correct command for development mode. It’s
npm run dev
and notnpm run start
. The start is for deployment, which works after anpm run build
.That’s what you should see in your
package.json
, in thescripts
part:Here is a simple solution that worked for me.
Check the version of your Node JS on your command prompt, type
node -p "process.arch"
If you are on 32bit, you’ll need to upgrade to 64bit, Install a new Node JS and then restart your PC, then it will work.