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

使用Jest执行npm test时遇Watchman报错,求解决方案

Fixing Jest/Watchman "Failed to open plist for write: Not a directory" Error

Hey there, let’s work through this frustrating issue with Jest and Watchman. The error you’re seeing points to a messed-up Watchman configuration file path—specifically, the system thinks com.github.facebook.watchman.plist is a directory instead of a file, which breaks Watchman (and in turn, Jest).

Here’s a step-by-step fix:

  1. Check the problematic path
    First, let’s confirm what’s actually in that LaunchAgents directory:
ls -la /Users/abhimanyuaryan/Library/LaunchAgents/

Look for com.github.facebook.watchman.plist—if you see it listed as a directory (marked with d at the start of the line), that’s the root cause.

  1. Remove the incorrect directory
    If it is a directory, delete it safely:
rm -rf /Users/abhimanyuaryan/Library/LaunchAgents/com.github.facebook.watchman.plist

Double-check you’re deleting the right thing—this shouldn’t affect any critical system files, just the messed-up Watchman entry.

  1. Reset or reinstall Watchman
    Next, let’s fix Watchman itself. If you installed it via Homebrew, you can fully reinstall it:
brew uninstall watchman
brew install watchman

Or if you prefer not to reinstall, reset Watchman’s state instead:

watchman watch-del-all
watchman shutdown-server
  1. Test again with Jest
    Run your test command once more:
npm test

Temporary workaround (if you need to test immediately)

If you just need to get tests running without fixing Watchman right now, you can disable Watchman in Jest:

  • Add this to your jest.config.js:
module.exports = {
  watchman: false,
};

Or run Jest directly with the flag:

jest --watchman false

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:04:22