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

在AWS Cloud9中使用create-react-app执行npm start遇问题求助

Troubleshooting React App Blank Page in AWS Cloud9 After Setting CHOKIDAR_USEPOLLING=true

Hey there, I’ve run into similar headaches when working with React apps in AWS Cloud9, so let’s break down how to fix this step by step:

  • Combine host binding with polling setting
    Cloud9 requires your app to listen on 0.0.0.0 (instead of the default localhost) to be accessible via its preview URL. When you set CHOKIDAR_USEPOLLING=true, you need to add the host configuration too. Try starting your app with this combined command:

    HOST=0.0.0.0 CHOKIDAR_USEPOLLING=true npm start
    

    After running this, use Cloud9’s "Preview Running Application" feature (top menu bar: Preview > Preview Running Application) to open the app. This usually resolves the blank page caused by the app not being reachable from the Cloud9 preview environment.

  • Set relative homepage path in package.json
    Cloud9’s preview URL uses a unique subdomain structure, which can cause React to load assets from the wrong path. Add a "homepage" field to your package.json file:

    {
      "name": "your-app-name",
      "homepage": ".",
      // rest of your package.json content
    }
    

    This tells React to use relative paths for all assets, preventing 404 errors that often lead to blank pages.

  • Clear cache and reinstall dependencies
    Corrupted dependencies or build caches can cause unexpected issues. Run these commands in your Cloud9 terminal:

    rm -rf node_modules package-lock.json
    npm cache clean --force
    npm install
    HOST=0.0.0.0 CHOKIDAR_USEPOLLING=true npm start
    
  • Check browser console for specific errors
    If the blank page persists, open your browser’s developer tools (F12) and check the Console tab for JavaScript errors, or the Network tab for failed asset loads (look for 404 status codes). These details will point you to the exact issue—like a missing module or incorrect asset path.

  • Verify Cloud9 environment security group (less likely but worth checking)
    Ensure your Cloud9 environment’s security group allows outbound HTTPS traffic (port 443). While Cloud9’s preview system usually handles this automatically, a restrictive security group could block asset downloads from CDNs or npm packages.

Give these steps a try in order—most of the time, combining the host binding and relative homepage setting fixes the blank page issue in Cloud9.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 04:31:03