Jest & lint fails with the following ERROR: NX ERROR spawn E2BIG

See original GitHub issue

Both my jest & lint fails with the following ERROR: NX ERROR spawn E2BIG

this is happening only on the CI pipeline. but the same works well in my local machine.

$ yarn affected:test 

yarn run v1.22.5
$ ./node_modules/.bin/nx affected:test --base=origin/test-code --parallel --detectOpenHandles --forceExit
>  NX   ERROR  spawn E2BIG
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
Jeffrey-Zuttcommented, Jan 22, 2022

OK. After some debugging I was able to resolve the issue in our repo. I’ll try to explain the solution, hopefully its useful for others as well.

Also: Thank you for building NX! It’s an awesome tool and we love using it.

Our setup:

1. We use cypress, and specify cypress cache folder like:

variables:
  CYPRESS_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/Cypress'

2. We specify a cache object to reuse among jobs:

.cache_deps: &cache_deps
  key:
    files:
      - yarn.lock
  paths:
    - cache/Cypress
    - node_modules

3. We have an ‘install’ job.

install:
  image: node:lts-slim
  cache:
    <<: *cache_deps
    policy: push
  script:
    - yarn install --frozen-lockfile

Note: cypress cache-folder amounts to almost 26.000 (!) files.

4. We have a ‘lint’ job.

lint:
  image: node:lts
  cache:
    <<: *cache_deps
    policy: pull
  script:
    - npx nx affected:lint --base=origin/master

Result:

$ npx nx affected:lint --base=origin/master
>  NX   ERROR  spawn E2BIG

The solution:

Cypress cache was adding ~26.000 files, which are all checked by the affected command, causing it to fail. Adding /cache (our custom cypress cache location) to .gitignore makes NX ignore all of these files.

The affected:lint command now run smoothly again for us.

4reactions
rubiagatracommented, Feb 14, 2022

Yep I am facing this is an issue also with freshly apps workspace and adding new node app using @nrwl/node generator

yarn run v1.22.17
$ nx serve

 >  NX   spawn E2BIG


error Command failed with exit code 1.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: spawn E2BIG - Questions - n8n community
Hi, I'm using the response of http request of a web page that returns a thread dump of java process (that could be...
Read more >
How to fix spawn ENAMETOOLONG error nrwl nx workspace
This error usually appears when you have too many uncommited files (in a range more than 700 or so in my experience).
Read more >
[PM2][ERROR] Process failed to launch spawn E2BIG - Medium
I dreamed about debugging for a long time and looking for a problem. It turned out that the problem is a stack overflow...
Read more >
passwords.txt - CMU School of Computer Science
... ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw nx ny nz oA oB...
Read more >
Error: spawn E2BIG #166 - Issuehunt
The issue has been closed. Error: spawn E2BIG #166. andreasgrimm posted onGitHub ... spawnWithSignal [as spawn] (child_process.js:717:17) at /Users/.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found