npm test dies with exception
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes.
Which terms did you search for in User Guide?
npm test
It is not the same as the problem described under npm test hangs on macOS Sierra.
Environment
node -v: v7.9.0npm -v: 4.2.0yarn --version(if you use Yarn):npm ls react-scripts(if you haven’t ejected): └── [email protected]
Then, specify:
- Operating system: macOS Sierra 10.12.6
- Browser and version (if relevant): Not relevant
I do not have watchman installed.
Steps to Reproduce
- create-react-app foo
- cd foo
- npm test
Expected Behavior
I expect the tests to run.
Actual Behavior
Output is:
RUNS src/App.test.js
2017-08-25 10:01 node[90950] (FSEvents.framework) FSEventStreamStart: register_w
RUNS src/App.test.js
2017-08-25 10:01 node[90950] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
throw er; // Unhandled 'error' event
^
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1050:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1376:11)
npm ERR! Test failed. See above for more details.
Reproducible Demo
See above steps to reproduce.
Workaround
Downgrading to "react-scripts": "1.0.10" fixes the problem.
What does ulimit -a say? Probably just need to bump the limit on open file descriptors.
Good suggestion.
$ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4864
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited
I tried increasing this:
ulimit -n 8192
Same error as before.
Do any of these suggestions help?
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-test-hangs-on-macos-sierra
I did try the suggestions that did not involve watchman (e.g., delete node_modules and run npm install), but they did not help. I saw in the discussion of the jest issue that some people could resolve the issue by installing watchman, but I would personally prefer to revert to the previous version of react-scripts until the underlying issue is fixed.
Same issue here with the same OS & react-scripts version (albeit npm 5.3.0 and node 8.4.0). Tests error out in exactly the same way. Installing Watchman (brew install watchman) solved the problem.
If Watchman is a requirement, can it be listed on the installation instructions & in the README? It seems like it's a dependency of various modules, at least according to my package-lock.json.
Honestly this issue is really widespread and @gaearon has said this should be fixed in jest or wherever the root cause is. See this issue for a huge comment thread.
I don't want to install watchman to be able to run tests, anyone have a lasting resolution.
I'm having this problem too, with a clean latest [email protected] ATM.
Running yarn test (react-scripts test --env=jsdom) does not help.
Installing watchman with brew also does not help, however running latest [email protected] directly does work, but with errors due to not having a proper babel/webpack config for imports (it's CRA), so unrelated, I think.
So I guess that jest is working and fixed, however CRA is not updated to use the latest jest?
node v8.6.0 yarn v1.2.1 MacOS Siera 10.12.6
No, CRA is not yet updated to latest Jest. Please don't try to manually install Jest into an existing CRA project; that won't work well.
I'm having the same problem, with a clean latest [email protected]. Downgrading to "react-scripts" v1.0.10 didn't solve the problem. Works fine after installing watchman with brew.
node v8.5.0 yarn v0.24.6 MacOS Siera 10.12.6
Was having same error on yarn test using:
node v8.9.0 yarn v0.20.3 MacOS Sierra 10.12.6
Same error after deleting /node_modules and re-installing using yarn install
Followed these instructions from readme to get yarn test working again:
watchman shutdown-server
brew update
brew reinstall watchman
I'm curious if this means that someone cloning my repo and trying to run tests will also need to have watchman installed?
Also having this problem. Was developing at work, tried to at home and it's broken now.
We'll switch to Jest 22 which uses fsevents under the hood when watchman isn't installed, so that should fix the issue. I'll close this as keeping it open won't help anyone.
@gaearon could you please release these changes?
They are already released in 2.x alpha. https://github.com/facebook/create-react-app/issues/3815
Note it’s an alpha so it is not stable and has other known issues.
Thanks @gaearon