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

部署基于Puppeteer的Node.js爬虫至Heroku遇H14错误求助

Let's work through your Heroku deployment issues one by one—first fixing the "No web processes running" and "Couldn't find that process type (web)" errors, then making sure Puppeteer plays nice with Heroku's environment.

1. Fix the Missing Web Process Error

Heroku has no idea what process to start for your app right now—that's why you're getting the "Couldn't find that process type (web)" message. Here's how to fix that with Yarn:

  • Double-check your package.json start script
    Open up your package.json and make sure there's a start command in the scripts section that points to your app's main file (like index.js or server.js):

    {
      "scripts": {
        "start": "node index.js"
      }
    }
    

    Swap index.js for whatever your actual entry file is named.

  • Create a Procfile
    In your project's root folder, make a file named Procfile (capital P, no file extension—this is important!) with this line:

    web: yarn start
    

    If your app needs to listen on a port, don't hardcode it—use process.env.PORT in your Node.js code instead. Heroku assigns this port automatically, so your app will pick it up seamlessly.

  • Deploy and scale the web dyno
    Commit your changes and push to Heroku:

    git add Procfile package.json
    git commit -m "Set up web process for Heroku deployment"
    git push heroku main
    

    Now run the scale command again—it should work without the error this time:

    heroku ps:scale web=1
    

2. Get Puppeteer Running Smoothly on Heroku

You've already added the right buildpacks, but there's a key configuration step you might be missing for Puppeteer:

  • Add mandatory launch arguments
    Heroku runs in a headless, restricted environment, so Puppeteer needs specific flags to start up without crashing. Update your launch code to include these args:

    const puppeteer = require('puppeteer');
    
    async function runScraper() {
      const browser = await puppeteer.launch({
        args: [
          '--no-sandbox', // Disables sandbox (required for Heroku's environment)
          '--disable-setuid-sandbox',
          '--disable-dev-shm-usage', // Fixes issues with limited shared memory on Heroku
          '--headless=new', // Uses the modern, more stable headless mode
          '--single-process'
        ]
      });
    
      // Your scraping logic goes here...
    
      await browser.close();
    }
    
  • Confirm buildpack order
    Heroku runs buildpacks in the order they're added, so make sure the Node.js buildpack comes before the Puppeteer one. Check your current buildpacks with:

    heroku buildpacks
    

    If they're out of order, fix it with these commands:

    heroku buildpacks:add --index 1 heroku/nodejs
    heroku buildpacks:add --index 2 https://github.com/jontewks/puppeteer-heroku-buildpack.git
    

3. Debug with Logs If You Still Hit Issues

If something's still not working, pull up Heroku's logs to see exactly what's going wrong:

heroku logs --tail

This will show you detailed error messages—like if Puppeteer is failing to launch, or your web server is crashing for some other reason.

内容的提问来源于stack exchange,提问作者sale108

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:26:45