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 /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-pilation. 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 pletely 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.
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.
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-pilation. 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 pletely 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/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.
1 Answer
Reset to default 6You are not using the correct mand for development mode. It's npm run dev
and not npm run start
. The start is for deployment, which works after a npm run build
.
That's what you should see in your package.json
, in the scripts
part:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},