Error: jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Do you want to request a feature or report a bug? bug
What is the current behavior?
When running jest in watch mode on the root directory of the project, jest-haste-map throws an error:
$ yarn test --watch
Using globally installed version of Yarn
yarn run v1.12.1
$ node node_modules/fbjs-scripts/node/check-dev-engines.js package.json
$ cross-env NODE_ENV=test jest --watch
jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
Error: Watchman error: resolve_projpath: None of the files listed in global config root_files are present in path `/Users/procidac/Development/gh/facebook/draft-js/src` or any of its parent directories. root_files is defined by the `/etc/watchman.json` config file and includes `.watchmanconfig`. One or more of these files must be present in order to allow a watch. Try pulling and checking out a newer version of the project?. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:167
throw er; // Unhandled 'error' event
^
Error: resolve_projpath: None of the files listed in global config root_files are present in path `/Users/procidac/Development/gh/facebook/draft-js/src` or any of its parent directories. root_files is defined by the `/etc/watchman.json` config file and includes `.watchmanconfig`. One or more of these files must be present in order to allow a watch. Try pulling and checking out a newer version of the project?
at BunserBuf.<anonymous> (/Users/procidac/Development/gh/facebook/draft-js/node_modules/fb-watchman/index.js:95:23)
at BunserBuf.emit (events.js:182:13)
at BunserBuf.process (/Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:292:10)
at /Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:247:12
at process._tickCallback (internal/process/next_tick.js:61:11)
Emitted 'error' event at:
at Client.client.on.error (/Users/procidac/Development/gh/facebook/draft-js/node_modules/jest-haste-map/build/lib/WatchmanWatcher.js:130:10)
at Client.emit (events.js:182:13)
at BunserBuf.<anonymous> (/Users/procidac/Development/gh/facebook/draft-js/node_modules/fb-watchman/index.js:107:12)
at BunserBuf.emit (events.js:182:13)
at /Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:249:12
at process._tickCallback (internal/process/next_tick.js:61:11)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This is similar to https://github.com/facebook/create-react-app/issues/346
What is the expected behavior? Jest starts in watch mode without errors
Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? This is happening in draft-js master with Node v10.14.2
I had this issue and it was because my Mac OS upgrade had removed permissions which watchman needed to watch files in the Documents directory. I went into System Preferences > Security & Privacy > Privacy > Files and Folders and manually gave watchman access.
Mas OS version: 10.15.1 Jest version: 22.1.4 watchman version: 4.9.0
at your root project location:
create a file named as .watchmanconfig and add {} as it's file content.
I have resolved this by doing this for my project. and @nigelrobbins3 answer also helped to solve it.
Based on @nigelrobbins3 remark above I ran brew uninstall watchman and brew install watchman to fix the problem.
Don't install your application in the Documents root directory, put it in a folder. It worked for me.
No

Yes

Based on @nigelrobbins3 remark above I ran
brew uninstall watchmanandbrew install watchmanto fix the problem.
brew reinstall watchman
Having the same issue, none of the above worked Mac 10.15.6 Node 14
I deleted the existing .watchmanconfig and created another one. Problem solved.
Having the same issue, none of the above worked Mac 10.15.6 Node 14
Same here, but am running MacOS 12 (Monterey). Did you find a solution?
Mine was due to watchman caching data from other react-native projects.
After I ran yarn clean (i.e. rm -rf $TMPDIR/react-* && watchman watch-del-all && yarn cache clean), the error went away.
@zrichardson8039 solution did the trick for me. I'm working with react-native in a yarn workspaces monorepo.
Running watch-del-all && yarn cache clean && react-native start --reset-cache solved it for me!
none of the above answers worked for me. Restarted my Mac and it worked.
Related issue
I have a Mac M1. I solved the issue by uninstalling watchman via brew. I had more luck using watchman installed via MacPorts.
brew uninstall watchman
sudo port install watchman
For react-native projects, I went into System Preferences > Security & Privacy > Privacy > Full Disk Access and manually gave access permission to the following.
- watchman
- Android Studio
- Visual Studio Code (If running command from VS code terminal)
@gamble2020 thanks. nothing was working but your solution worked.
I just reinstall watchman (brew reinstall watchman) and restart my macBook. It helps. Note: make sure that your terminal has Full Disk Access permission in MacBook settings
https://stackoverflow.com/a/72571937/15190933
I tried to just uninstall watchman and it worked for me.
brew uninstall watchman
I tried to just uninstall watchman and it worked for me.
brew uninstall watchman
Thank You it`s help full me
@kaushal-yadav It helped me too. Why is that?
If you uninstall watchman you don't get any of its benefits..
uninstall watchman worked for me.
but it's so weird... I tried several hours to make it work with watchman...
And actually if I uninstall watchman, I ran into this issue https://github.com/facebook/watchman/issues/923
So I got a catch-22.
@kaushal-yadav It helped me too. Why is that?
The thing that I found
You're running watchman as root but the state dir, which may contain trigger definitions and thus allow spawning arbitrary commands, is not owned by root. This is a security issue and thus watchman is refuses to start.
It wants full disk access if you give that it will work. But we don't want to give full disk access
I tried to just uninstall watchman and it worked for me.
brew uninstall watchman
thanks! its works for me
I found a solution. Move the folder from the project to the directory: Users/shared folder

My computer is controlled by the company who I work for, and I'm not able to add watchman to the system preferences/Security and privacy/Privacy.... , so I moved the project to /Users/myusername/ ...and it started to work.
Hope this will be helpful. worked for me.
You should move the entire project directory outside of the Documents or Download directory for mac
https://github.com/facebook/watchman/issues/977
So just to add more context to this. I had a similar issue in the react native project. It turns out this started when I was trying to install watchman to eject the project from expo. I uninstalled the watchman and did not re-install it. That worked for me and expo started working again for me!
First run watchman watch-del-all
then run watchman shutdown-server
Running
watch-del-all && yarn cache clean && react-native start --reset-cachesolved it for me!
watchman watch-del-all && yarn cache clean && react-native start --reset-cache work for me!
In my case, I have an m1 MacBook pro, I had to just uninstall watchman with brew uninstall watchman and it worked.
In case reinstalling watchman on macOS does not work, do:
brew uninstall watchman
killall watchman
brew install watchman
This will prompt for access to the Documents folder on the next launch of watchman, which should resolve the permissions issue.
Just Restart your system. Helped in my case.
I deleted the existing
.watchmanconfigand created another one. Problem solved.
Saved my life. Thanks.
none of the above answers worked for me. Restarted my Mac and it worked.
Yes, restarted my Mac worked for me also. At login it asked Watchman for permission in the project folder. Odd.
Also: if you created a .watchmanconfig empty file in the root of the project following some of the above suggestions: remove it or fill it with
{}