create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

npm test dies with exception

Open ciyer opened this issue 9 years ago • 15 comments

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

  1. node -v: v7.9.0
  2. npm -v: 4.2.0
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven’t ejected): └── [email protected]

Then, specify:

  1. Operating system: macOS Sierra 10.12.6
  2. Browser and version (if relevant): Not relevant

I do not have watchman installed.

Steps to Reproduce

  1. create-react-app foo
  2. cd foo
  3. 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.

ciyer avatar Aug 25 '17 08:08 ciyer

What does ulimit -a say? Probably just need to bump the limit on open file descriptors.

heyimalex avatar Aug 25 '17 18:08 heyimalex

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.

ciyer avatar Aug 25 '17 19:08 ciyer

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

gaearon avatar Aug 25 '17 20:08 gaearon

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.

ciyer avatar Aug 25 '17 20:08 ciyer

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.

davidjb avatar Sep 06 '17 00:09 davidjb

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.

leetercola avatar Sep 15 '17 14:09 leetercola

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

v1adko avatar Oct 24 '17 15:10 v1adko

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.

gaearon avatar Oct 24 '17 16:10 gaearon

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

misidoro avatar Nov 01 '17 12:11 misidoro

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?

amaidah avatar Nov 11 '17 20:11 amaidah

Also having this problem. Was developing at work, tried to at home and it's broken now.

mackbrowne avatar Nov 25 '17 16:11 mackbrowne

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 avatar Jan 08 '18 22:01 gaearon

@gaearon could you please release these changes?

edoroshenko avatar Jan 23 '18 10:01 edoroshenko

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.

gaearon avatar Jan 23 '18 11:01 gaearon

Thanks @gaearon

edoroshenko avatar Jan 24 '18 09:01 edoroshenko