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

Nodemon修改代码后触发两次重启问题求助

Fixing Nodemon Restarting Twice with Atom IDE

I’ve run into this exact annoying issue before when pairing Atom with nodemon—those duplicate logs make it impossible to track what’s actually happening. Let’s walk through the most reliable fixes to get rid of that double restart:

1. Disable Atom’s Safe Save Feature

Atom has a default "Safe Save" setting that creates a temporary file first, then replaces your original file. Nodemon detects both the temp file creation and the original file update, triggering two restarts in a row. Here’s how to turn it off:

  • Open Atom’s Settings (press Ctrl+, or go to File > Settings)
  • Search for "Safe Save" in the top search bar
  • Uncheck the box next to "Enable Safe Save"

2. Tell Nodemon to Ignore Editor Temp Files

Atom generates hidden temporary/swap files when you edit, and nodemon might be picking those up as "changes." Create a nodemon.json file in your project root to exclude these files:

{
  "ignore": [
    ".git",
    "node_modules",
    "*.swp",
    "*.tmp",
    ".atom/**"
  ]
}

Or add the ignore flags directly to your package.json script if you prefer:

"scripts": {
  "dev": "nodemon --ignore '*.swp' --ignore '*.tmp' app.js"
}

3. Update Nodemon to the Latest Version

Occasionally, double-restart bugs get patched in newer nodemon releases. Run one of these commands to update:

# Update global nodemon
npm install -g nodemon

# Update local project nodemon
npm install nodemon --save-dev

4. Test with Manual Saves First

If you have Atom’s auto-save enabled, try turning it off temporarily and saving changes manually (Ctrl+S). Auto-save can sometimes trigger multiple file change events that nodemon misinterprets as separate updates.

After trying these steps, make a small code tweak and save—you should only see one [nodemon] starting node app.js line followed by your single "Connected to db..." log.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:46:28