NextJS 项目,编译成功,但是启动失败的解决方案
前言
在刚刚我写的文章 《Next.js V15 在异步页面中,获取路由动态参数的几个坑》 中,我顺利的编译好开发的项目了。于是很开心的去吃个了晚饭,回来后,想启动了看看,在生产模式下是否有什么问题。
非常意外的,出问题了,连刚刚吃下午的小龙虾都不香了。
编译成功后,启动失败的错误信息
报错信息如下:
为便于搜索引擎抓取,为有同样问题的朋友方便搜索,具体的报错代码如下,看解决方案的朋友跳过。
next start -p 3010▲ Next.js 15.1.8- Local: http://localhost:3010- Network: http://192.168.8.11:3010✓ Starting...✓ Ready in 277ms⨯ Error: Expected to use Webpack bindings (react-server-dom-webpack/server.edge) for React but the current process is referencing 'createClientModuleProxy' from the Turbopack bindings (react-server-dom-turbopack/server.edge). This is likely a bug in our integration of the Next.js server runtime.at [project]/node_modules/.pnpm/next@15.1.8_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.66.0/node_modules/next/dist/client/components/error-boundary.js (client proxy) <module evaluation> (.next/server/chunks/ssr/3fa86_next_dist_c15ec7._.js:15524:9)at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:590:23)at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:645:12)at esmImport (.next/server/chunks/ssr/[turbopack]_runtime.js:132:20)at [project]/node_modules/.pnpm/next@15.1.8_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.66.0/node_modules/next/dist/client/components/error-boundary.js [app-rsc] (ecmascript) (.next/server/chunks/ssr/3fa86_next_dist_c15ec7._.js:15539:336)at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:590:23)at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:645:12)at esmImport (.next/server/chunks/ssr/[turbopack]_runtime.js:132:20)at [project]/node_modules/.pnpm/next@15.1.8_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.66.0/node_modules/next/dist/esm/build/templates/app-page.js?page=/_not-found/page { METADATA_0 => "[project]/src/app/favicon.ico.mjs { IMAGE => \"[project]/src/app/favicon.ico [app-rsc] (static)\" } [app-rsc] (structured image object, ecmascript, Next.js server component)", MODULE_1 => "[project]/src/app/layout.tsx [app-rsc] (ecmascript, Next.js server component)", MODULE_2 => "[project]/node_modules/.pnpm/next@15.1.8_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.66.0/node_modules/next/dist/client/components/not-found-error.js [app-rsc] (ecmascript, Next.js server component)" } [app-rsc] (ecmascript) <module evaluation> (.next/server/chunks/ssr/_8a4e3e._.js:262:325)
解决方案
见鬼了,把报错代码扔给 DeepSeek,结果这货又开始胡言乱语了:
看来是指不上 DeepSeek 了。搜索引擎开干,终于找到了病友和解决方案。
参考资料地址:https://github.com/vercel/next.js/discussions/61804
根据遇到相同问题的网友的经验,解决这个问题的方案就是—— 重新编译一下!
于是 pnpm run build
走起,再次运行项目:
这 TM 都哪儿跟哪儿啊这是!
看来是 NextJS 底层有点什么 BUG 导致的这个问题,导致在编译过程中,有几率发生这样的小故障。如果看官你也遇到了同样的问题,也可以和我一样,重新编译一下。大不了,多编译几下。
还好,项目快收尾了。这个世界,还真是个草台班子~
文章没啥实际内容,纯粹是水了一篇,只为方便遇到同样问题的朋友。所以,点个赞再走吧~