You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Plesk中部署Next.js应用启动失败:模块未找到及页面无限加载问题求助

Troubleshooting Next.js Deployment Issues on Plesk

Hey there, let's work through the problems you're facing with deploying your Next.js app on Plesk—since your build process works fine, we can focus on the startup and runtime issues.

1. Fixing "Cannot find module '../build/output/log'" Error

This error almost always ties to mismatched build output paths or incorrect startup commands. Here's how to resolve it:

  • Verify your package.json scripts:
    Make sure your scripts look like this (adjust for Yarn if needed):
    {
      "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start -p 8080" // Use a port not blocked by Plesk
      }
    }
    
    Next.js 12+ generates a .next folder (not an older build folder) after next build, so the start command doesn't need custom paths—it automatically uses the .next output.
  • Check Plesk application settings:
    In your Plesk Node.js app configuration:
    • Set Application root to your project's root directory (where package.json lives).
    • Leave Startup file empty, or set it to node_modules/next/dist/bin/next (this tells Plesk to use Next's built-in server).
    • Ensure the Command field uses start -p [your-port] (match the port in your start script).

2. Resolving Infinite Page Load / No Response

If your app starts but the page hangs, these are the most likely fixes:

  • Port & Reverse Proxy Setup:
    • Pick a unique port (e.g., 8080, avoid 3000 if it's used by other services) and confirm it's allowed in your server's firewall (Plesk has a firewall tool under "Security" to open the port).
    • Configure Plesk's reverse proxy to forward your domain traffic to the port your Next.js app uses. Go to your domain's "Apache & Nginx Settings" and add a custom Nginx rule like:
      location / {
          proxy_pass http://localhost:8080;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
      
  • Check Runtime Logs:
    In Plesk, navigate to your app's "Logs" tab—this will show you if there are hidden errors (like failed API routes or missing environment variables) that aren't showing up in the browser.
  • Avoid Dev Mode in Production:
    Never use npm run dev to start your production app—it's for development only. Always run npm run build first, then npm run start.

3. Fixing "Error build module not found"

This usually happens when dependencies are missing or build artifacts are incomplete:

  • Reinstall Dependencies:
    In Plesk's terminal, navigate to your project root and run:
    rm -rf node_modules package-lock.json .next
    npm install --production=false
    
    The --production=false flag ensures all development dependencies (which Next.js needs for building) are installed.
  • Check Ignore Files:
    Make sure your .gitignore or .npmignore isn't accidentally excluding critical folders like pages/, components/, or public/—these are required for Next.js to build and run correctly.
  • Match Node.js Versions:
    Ensure the Node.js version in Plesk matches what you used locally for development. You can switch versions in Plesk's Node.js app settings under "Node.js version".

内容的提问来源于stack exchange,提问作者Luca Schönherr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 17:23:13