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

Angular使用ng serve时自动重载问题咨询(仅个人iMac出现)

Fixing Unwanted Auto-Reload in Angular ng serve on Late 2013 iMac (High Sierra)

Hey there, let's tackle this frustrating auto-reload issue that's only popping up on your older iMac. I've dealt with similar macOS-specific quirks before, so here are some targeted fixes to try:

  • Adjust File System Limits
    Older macOS versions like High Sierra have stricter limits on how many files the system can monitor at once, which can cause Angular's live-reload to misbehave. Run these commands in your terminal to temporarily bump the limits:

    sysctl -w kern.maxfiles=524288
    sysctl -w kern.maxfilesperproc=524288
    

    To make this change permanent, create or edit /etc/sysctl.conf and add those two lines, then restart your computer.

  • Exclude Your Project from Spotlight Indexing
    Spotlight might be constantly indexing files in your Angular project, triggering false change detections. Here's how to stop that:

    1. Open System Preferences → Spotlight → Privacy
    2. Drag your entire Angular project folder into the list of excluded locations
    3. Restart ng serve and see if the auto-reload calms down
  • Verify Angular CLI & Dependency Version Match
    Mismatched CLI and Angular core package versions often cause weird behavior. Run ng version in your project root to check:

    • Ensure @angular/cli and @angular/core versions are closely aligned (e.g., both 12.x or both 14.x)
    • If they don't match, either update the CLI to match your project (npm install @angular/cli@<your-project-version>) or update your project dependencies to match the CLI
  • Wipe Caches & Reinstall Dependencies
    Corrupted cache files can trigger false reloads. Follow these steps to reset:

    npm cache clean --force
    rm -rf node_modules
    rm package-lock.json
    npm install
    rm -rf dist
    ng serve
    
  • Exclude Temporary/Editor Files from Monitoring
    Some editors generate backup or swap files (like VS Code's .swp files, or files ending in ~) that Angular might mistake for real changes. Add these exclusions to your angular.json:
    Navigate to projects → [your-project-name] → architect → build → options and add:

    "exclude": ["**/*.swp", "**/*~", "**/.DS_Store"]
    

Give these steps a try one at a time—chances are one of them will fix that unwanted auto-reload. Let me know if you run into any roadblocks!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:35:20