react-scripts test is watching files in node_modules
See original GitHub issueCan you reproduce the problem with latest npm?
yes
Can you still reproduce it?
yes, also did npm cache clean
just to be sure
Description
This is a followup of “npm test hangs for newly generated app (#960)”. After reading the comment of @hmeerlo that “Jest is trying to watch too many files at once (https://github.com/facebook/jest/issues/1767#issuecomment-250719565)” I suspect that files in node_modules are unnecessarily being watched.
Expected behavior
npm t
should run without error.
Actual behavior
react-scripts test --env=jsdom
2017-05-28 09:18 node[1154] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-28 09:18 node[1154] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:160
throw er; // Unhandled 'error' event
^
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1018:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1420:11)
npm ERR! Test failed. See above for more details.
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.7node -v
: v6.10.3npm -v
: 4.6.1
Then, specify:
- Operating system: macOS Sierra 10.12.5
- Browser and version: -
watchman
never installed
Reproducible Demo
https://github.com/thisconnect/cra-desktop
Reproduce the error
This is an instantiated create-react-app (un-ejected) with electron
added as described in PR https://github.com/facebookincubator/create-react-app/pull/1718
git clone https://github.com/thisconnect/cra-desktop
cd cra-desktop
npm install
npm test
Without error (when removing 2 large dependencies)
Assuming react-scripts test
is indeed watching files in node_modules, remove electron
and electron-packager
from devDependencies in package.json, then rm -rf node_modules && npm i && npm t
, test mode runs fine. This does not yet prove that files in node_modules are being watched.
Strong indication that node_modules is being watched:
- run any CRA instance without error
- the Terminal should display something like “No tests found related to files changed since last commit” and the “Watch Usage”
- open a random .js file in node_modules
- for example node_modules/mime/mime.js
- watch the Terminal (screenshot 1)
- add a comment on any line i.e.
// test
- save the file
- check if the terminal changed (screenshot 2)
Terminal before changing a random file in node_modules (screenshot 1)
Terminal after chaning a random file in node_modules (screenshot 2)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:18 (8 by maintainers)
Top GitHub Comments
Reinstalling watchman fixed this error for me.
brew uninstall watchman brew install watchman
I did a
sudo port install watchman
, and problem went away.Apparently you need watchman installed.