JingXiao
V2EX  ›  Next.js

为啥 nextjs 编译这么慢,除了加物理内存,有啥好的优化建议?

  •  
  •   JingXiao · Aug 25, 2025 · 3026 views
    This topic created in 279 days ago, the information mentioned may be changed or developed.
    最近项目在魔改 dify ,用的 nextjs 技术栈,虚拟机 8g 内存直接本地跑不起来,所以目前只能盲打代码提交 git ,服务器端打包部署测试环境看效果。
    主要自己本子 mba m1 16G 内存拉了 dify 代码安装了相关服务本地跑,也勉强跑起来,然后就是编译巨慢啊,改个东西要好久才能编译完成,但是感觉页面内容也不复杂啊,一般慢也就等几秒热更新,这个起码要等十几秒。

    nextjs13 的时候也去学习过,好像也没这么慢,现在 app router 模式咋这么慢,有啥建议不,感觉开发体验好差。谢谢。
    7 replies    2026-05-29 10:51:05 +08:00
    mooyo
        1
    mooyo  
       Aug 25, 2025   ❤️ 1
    除了换 vite 没啥好的解决办法吧,我自己写的一个小项目用 nextjs 也是巨慢。
    Wxh16144
        2
    Wxh16144  
       Aug 25, 2025   ❤️ 1
    插眼,我感觉是无解.. ,试试 turbopack 模式?
    Razio
        3
    Razio  
       Aug 25, 2025   ❤️ 1
    或者改 remix 试试。
    Hanser002
        4
    Hanser002  
       Aug 25, 2025   ❤️ 1
    remix or tanstack-router
    razertory
        5
    razertory  
       Sep 28, 2025
    刚刚 把一个 Next.js 项目改成了 Remix (
    @ReactRouterV7) 项目, 在一台 1 core 1g 的 Racknerd 机器上,构建时间从 5min 降低到了 1min 。

    如果 Nextjs 的迭代目标还是在继续为了维护 Vercel 的护城河,会有更多开发者离去
    swordHeart
        6
    swordHeart  
       Dec 26, 2025
    着实想不通
    JingXiao
        7
    JingXiao  
    OP
       2 days ago
    2026 年找到了相对还行的解决方案,就是用 vinext 来启动 nextjs ,这样也不用改原来的项目,老机子也能跑起来
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2700 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 12:18 · PVG 20:18 · LAX 05:18 · JFK 08:18
    ♥ Do have faith in what you're doing.