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

Ionic实时预览失效,保存时报events.js:160错误求解决方案

Fixing Ionic Live Reload ECONNRESET Error (Requires Restarting Serve/Lab After Changes)

Hey, I’ve dealt with this exact ECONNRESET issue messing up Ionic’s live reload before—it’s such a buzzkill when you’re trying to iterate quickly! Let’s go through practical fixes that resolved it for me and other devs:

Quick Initial Troubleshooting

  • Kill all residual processes: Close every VS Code window, terminal tab, and any Node.js/Ionic-related background processes (use Task Manager/Activity Monitor if needed), then restart your computer. Stale processes often hold onto ports or corrupt connections.
  • Clear caches and reinstall dependencies:
    # Clean Ionic cache
    ionic cache clean
    # Clean Node's npm cache
    npm cache clean --force
    
    Then delete your node_modules folder and package-lock.json (or yarn.lock), run npm install to fresh-install all dependencies.

Change Live Reload Port

The default live reload port (usually 35729) might be blocked by another app. Try switching it:

  • Start your dev server with a custom port:
    ionic serve --livereload-port 8101
    # Or for Ionic Lab
    ionic lab --livereload-port 8101
    
  • To make this permanent, add the port to your ionic.config.json:
    {
      "name": "your-app-name",
      "integrations": {},
      "type": "angular",
      "liveReloadPort": 8101
    }
    

Check Firewall/Antivirus Interference

Sometimes security software blocks the live reload connection. Temporarily disable your firewall or antivirus, then test saving a file. If the error goes away, add exceptions for Ionic’s default ports (8100, 35729) to your security tool.

Update Ionic CLI and Node.js

Outdated versions can have known live reload bugs:

  • Update Ionic CLI to the latest stable version:
    npm install -g @ionic/cli
    
  • Ensure you’re using a Node.js LTS version (avoid bleeding-edge or extremely old releases)—Ionic maintains compatibility with LTS versions best.

Test a Fresh Ionic Project

If none of the above works, create a new blank Ionic project and check if live reload works there:

ionic start test-app blank --type angular
cd test-app
ionic serve

If the fresh project works fine, your original project likely has a corrupted config file (like angular.json or ionic.config.json). Compare the configs from the test project to your existing one and fix any discrepancies.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:04:44