Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Error: jest-haste-map: Watchman crawl failed. Retrying once with node crawler. #2183

Open
claudiopro opened this issue Sep 19, 2019 · 43 comments

Comments

@claudiopro
Copy link
Contributor

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 facebook/create-react-app#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

@nigelrobbins3
Copy link

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

@AmitPandya007
Copy link

AmitPandya007 commented Dec 18, 2019

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.

@jleach
Copy link

jleach commented Apr 27, 2020

Based on @nigelrobbins3 remark above I ran brew uninstall watchman and brew install watchman to fix the problem.

@paulohcardoson
Copy link

Don't install your application in the Documents root directory, put it in a folder. It worked for me.

No
Captura de Tela 2020-07-24 às 23 07 15

Yes
Captura de Tela 2020-07-24 às 23 08 03

@JSONRice
Copy link

Based on @nigelrobbins3 remark above I ran brew uninstall watchman and brew install watchman to fix the problem.

brew reinstall watchman

@jbesraa
Copy link

jbesraa commented Oct 28, 2020

Having the same issue, none of the above worked
Mac 10.15.6
Node 14

@Ogala
Copy link

Ogala commented Mar 18, 2021

I deleted the existing .watchmanconfig and created another one. Problem solved.

@AdamGerthel
Copy link

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?

@zrichardson8039
Copy link

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.

@Enricopv
Copy link

@zrichardson8039 solution did the trick for me. I'm working with react-native in a yarn workspaces monorepo.

@Dajust
Copy link

Dajust commented Jan 6, 2022

Running watch-del-all && yarn cache clean && react-native start --reset-cache solved it for me!

@yosoyafa
Copy link

yosoyafa commented Jun 2, 2022

none of the above answers worked for me. Restarted my Mac and it worked.

@shoopi12
Copy link

shoopi12 commented Jun 3, 2022

Related issue

@gamble2020
Copy link

gamble2020 commented Jun 4, 2022

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

Install MacPorts

sudo port install watchman

@AnuragHarod
Copy link

AnuragHarod commented Jun 6, 2022

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)

@sahilbakoru
Copy link

@gamble2020 thanks. nothing was working but your solution worked.

@ziginsider
Copy link

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

@yusufusta
Copy link

https://stackoverflow.com/a/72571937/15190933

@kaushal-yadav
Copy link

I tried to just uninstall watchman and it worked for me.
brew uninstall watchman

@hetramjanghu
Copy link

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

Thank You
it`s help full me

@dev-event
Copy link

@kaushal-yadav It helped me too. Why is that?

@shoopi12
Copy link

If you uninstall watchman you don't get any of its benefits..

@chinalwb
Copy link

chinalwb commented Jun 20, 2022

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 facebook/watchman#923

So I got a catch-22.

@kaushal-yadav
Copy link

kaushal-yadav commented Jun 21, 2022

@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 

@nguyenthanh1205tb
Copy link

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

thanks! its works for me

@dev-event
Copy link

dev-event commented Jun 21, 2022

I found a solution. Move the folder from the project to the directory: Users/shared folder
Снимок экрана 2022-06-21 в 11 35 51

@gersonmontenegroepam
Copy link

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.

@manirikhi
Copy link

Hope this will be helpful. worked for me.

You should move the entire project directory outside of the Documents or Download directory for mac

facebook/watchman#977

@shazimajaz1
Copy link

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!

@rishiankush
Copy link

First run watchman watch-del-all
then run watchman shutdown-server

@saronlujan
Copy link

Running watch-del-all && yarn cache clean && react-native start --reset-cache solved it for me!

watchman watch-del-all && yarn cache clean && react-native start --reset-cache work for me!

@josephflerime
Copy link

In my case, I have an m1 MacBook pro, I had to just uninstall watchman with brew uninstall watchman and it worked.

@slhck
Copy link

slhck commented Jul 28, 2022

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.

@mohit2605
Copy link

Just Restart your system. Helped in my case.

@hokimtam
Copy link

hokimtam commented Aug 1, 2022

I deleted the existing .watchmanconfig and created another one. Problem solved.

Saved my life. Thanks.

@nemwiper
Copy link

nemwiper commented Aug 3, 2022

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

{}

@whatapangolin
Copy link

Mac M1
Give full disk access to watchman solved my prob.

@mucahitdev
Copy link

restart my mac m1

@patrickmuhi
Copy link

First run watchman watch-del-all
then run watchman shutdown-server fixed my issue

@codershona
Copy link

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

It worked for me by uninstalling watchman in macbook pro m1. I was first all install watchman by running brew install watchman and then give full disk access watchman and my terminal including VSC editor in the security and privacy of system preferences. But it was not working. Then once i run brew uninstall watchman now after restarting my terminal i run npm test and everything is working fine.

@KrisLau
Copy link

KrisLau commented Oct 13, 2022

  1. watchman watch-del-all
  2. watchman shutdown-server

Worked for me

@imamrobani
Copy link

First run watchman watch-del-all then run watchman shutdown-server

I got this issue after the update watchman.
so I try this solution. this work for me, thanks.

@benhurley
Copy link

  1. watchman watch-del-all
  2. watchman shutdown-server

Worked for me

This worked for me too, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests