我开始了我的项目,到目前为止一切顺利.
npm run start
> mk-market@0.1.0 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
但在此之后,不再有控制台输出,也不是在发出请求和不将更改保存在我的文件中时,它将输出服务器端console.logs()
.
该页面在我的浏览器中工作(在localhost:3000
).但是当我保存更改时(比方说添加<h1>Hello</h1>
),我得不到自动重新编译.npm run start
也不会有任何改变.获取新保存的更改的唯一方法是先运行npm run build
,然后运行npm run start
我以前也遇到过这种情况,让它重新运转的唯一方法就是启动一个全新的项目.但我现在已经走得有点太远了.
我疯狂地用谷歌搜索,但我能找到的唯一与我密切相关的是我应用程序文件夹中页面命名的大写字母,但这里不是这样.
另外,我刚刚用npm create-next-app
创建了一个全新的项目,但同样的事情正在发生.当运行npm run start
时,我得到:
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'
}
我必须跑npm run build
才能运行它,我不记得过go 为新项目做过这样的事情.