yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

yarn command fail,prompt Reached heap limit Allocation failed - JavaScript heap out of memory。 #8734

Open Crest2333 opened 2 years ago

Crest2333 commented 2 years ago

C:\Users\38427>yarn -v 1.22.15

C:\Users\38427>yarn config list yarn config v1.22.15

<--- Last few GCs --->

[8180:000002315B904480] 604234 ms: Mark-sweep 10082.6 (10273.8) -> 10079.2 (10284.0) MB, 10573.7 / 0.0 ms (average mu = 0.322, current mu = 0.136) task scavenge might not succeed [8180:000002315B904480] 621640 ms: Mark-sweep 10091.9 (10284.0) -> 10086.2 (10290.5) MB, 17041.1 / 0.0 ms (average mu = 0.168, current mu = 0.021) task scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF70A1C013F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112495 2: 00007FF70A14F396 DSA_meth_get_flags+65526 3: 00007FF70A15024D node::OnFatalError+301 4: 00007FF70AA819EE v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF70AA6BECD v8::SharedArrayBuffer::Externalize+781 6: 00007FF70A90F61C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468 7: 00007FF70A90C754 v8::internal::Heap::CollectGarbage+4244 8: 00007FF70A8BC3B5 v8::internal::IndexGenerator::~IndexGenerator+22165 9: 00007FF70A0E0E9F v8::CFunctionInfo::HasOptions+22111 10: 00007FF70A0DF6B6 v8::CFunctionInfo::HasOptions+15990 11: 00007FF70A21F25B uv_async_send+331 12: 00007FF70A21E9EC uv_loop_init+1292 13: 00007FF70A21EB8A uv_run+202 14: 00007FF70A1EDC95 node::SpinEventLoop+309 15: 00007FF70A107AC3 cppgc::internal::NormalPageSpace::linear_allocation_buffer+53827 16: 00007FF70A184FBD node::Start+221 17: 00007FF709FA88CC RC4_options+348108 18: 00007FF70B0008F8 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+14472 19: 00007FFAE08A4034 BaseThreadInitThunk+20 20: 00007FFAE3013691 RtlUserThreadStart+33

Ffloriel commented 2 years ago

Similar issue when install purgecss-webpack-plugin in some situation: https://github.com/FullHuman/purgecss/issues/700

Reproduction

This is my very basic repo https://github.com/teekenl/test-purge-css, so if you pulled down and run yarn install before trying to run yarn add purgecss-webpack-plugin you will get the error.

Copy of the issue above

Describe the bug Got into memory exceeded limit error when trying to install the plugin using yarn

To Reproduce Steps to reproduce the behavior:

  1. Go to terminal - install
  2. Run yarn add purgecss-webpack-plugin
  3. See error

Note: have tried the following:

  1. export NODE_OPTIONS= --max_old_space_size=16000

Expected behavior should install successfully

Screenshots

❯ yarn add purgecss-webpack-plugin                
yarn add v1.22.10
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > extract-text-webpack-plugin@3.0.2" has incorrect peer dependency "webpack@^3.1.0".
warning " > webpack-manifest-plugin@1.3.2" has incorrect peer dependency "webpack@1 || 2 || 3".
<--- Last few GCs --->
[1585:0x1046ab000]   934298 ms: Scavenge (reduce) 15963.4 (16020.1) -> 15963.0 (16020.6) MB, 27.0 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
[1585:0x1046ab000]   934322 ms: Scavenge (reduce) 15963.7 (16017.6) -> 15963.3 (16018.9) MB, 21.4 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
[1585:0x1046ab000]   934345 ms: Scavenge (reduce) 15964.0 (16020.9) -> 15963.7 (16021.4) MB, 20.4 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1012d96a5 node::Abort() (.cold.1) 
 2: v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) 
 3: 0x100395df5 v8::internal::Heap::FatalProcessOutOfMemory(char const*)
 4: 0x10039789a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) 

Environment (please complete the following information):

Crest2333 commented 2 years ago

I have set NODE_OPTIONS=16000,but, still fail,any yarn command will fail,except yarn -v. My Environment Node version - 14.18.1 OS: win 10 Package - purgecss yarn version - 1.22.17 image

alvaroschipper commented 2 years ago

Suddenly started facing the same issue, tried updating to latest v1 and changing node versions but no luck so far :(

EmanoelFaria commented 2 years ago

me too, i have change anything, there is no resolution for this problem?

ttomaszewski commented 2 years ago

+1, just started happening today with yarn add

erezrokah commented 2 years ago

Happening with netlify-cli too https://github.com/netlify/cli/issues/3788 without any change to the CLI.

Happens with multiple versions of the CLI, Node.js and Yarn

erezrokah commented 2 years ago

Opened an issue on the dependency that's causing it for netlify-cli, see https://github.com/oclif/plugin-help/issues/349.

However this is a yarn issue as using npm works.

ehmicky commented 2 years ago

I work with @erezrokah on netlify-cli. From our additional debugging, it seems like the problem is happening due to a circular dependency between two packages (i.e. they depend on each other). In our case, it is @oclif/plugin-help and @oclif/command. However, the bug only triggers when also using the npm: prefix on the version of one of them, as shown here.

a-eid commented 2 years ago

having a similar issue, not sure what's causing it

warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > zeal-ui > react-native-style-utilities@1.0.1" has unmet peer dependency "react@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > zeal-ui > react-native-style-utilities@1.0.1" has unmet peer dependency "react-native@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > @testing-library/react-hooks@3.7.0" has unmet peer dependency "react@>=16.9.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > @testing-library/react-hooks@3.7.0" has unmet peer dependency "react-test-renderer@>=16.9.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > ts-jest@26.3.0" has unmet peer dependency "jest@>=26 <27".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > brgr > react-native > react-native-codegen > jscodeshift@0.13.1" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > eslint-config-universe > @typescript-eslint/eslint-plugin@4.33.0" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > eslint-config-universe > @typescript-eslint/parser@4.33.0" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo > react-test-renderer@16.11.0" has unmet peer dependency "react@^16.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/enzyme-adapter-react-17@0.6.6" has unmet peer dependency "react@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/enzyme-adapter-react-17@0.6.6" has unmet peer dependency "react-dom@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-enzyme@7.1.2" has unmet peer dependency "jest@>=22.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > react-test-renderer@17.0.2" has unmet peer dependency "react@17.0.2".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/enzyme-adapter-react-17 > @wojtekmaj/enzyme-adapter-utils@0.1.4" has unmet peer dependency "react@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-enzyme > jest-environment-enzyme@7.1.2" has unmet peer dependency "jest@>=22.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-enzyme > jest-environment-enzyme@7.1.2" has unmet peer dependency "react@^0.13.0 || ^0.14.0 || ^15.0.0 || >=16.x".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-expo > jest-watch-typeahead@0.6.4" has unmet peer dependency "jest@^26.0.0 || ^27.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-maps@0.29.4" has unmet peer dependency "react-native-web@>= 0.11".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > dashboard > react-native-modal-datetime-picker@13.1.2" has incorrect peer dependency "react-native@>=0.65.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-vector-image@0.3.3" has incorrect peer dependency "@klarna/react-native-vector-drawable@^0.1.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-vector-image@0.3.3" has unmet peer dependency "metro@>=0.58.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-vector-image@0.3.3" has unmet peer dependency "metro-config@>=0.58.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base@3.4.4" has unmet peer dependency "@types/react@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base@3.4.4" has unmet peer dependency "react-dom@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-map-link > react-native-modal@13.0.1" has incorrect peer dependency "react-native@>=0.65.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/overlays@0.3.3-rc.0" has unmet peer dependency "react-dom@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > team > expo-camera > @koale/useworker@4.0.2" has incorrect peer dependency "react@^16.8.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > coffee-berry > react-native > react-native-codegen > jscodeshift@0.11.0" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/combobox@3.2.6" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/overlays@3.8.2" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/live-announcer@3.0.6" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/combobox > @react-aria/menu@3.4.4" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".

<--- Last few GCs --->

[35655:0x7fb3e0008000]   132757 ms: Scavenge 4040.7 (4122.2) -> 4037.9 (4123.7) MB, 27.1 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure
[35655:0x7fb3e0008000]   133114 ms: Scavenge 4042.1 (4123.7) -> 4040.0 (4126.5) MB, 316.0 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure
[35655:0x7fb3e0008000]   133935 ms: Scavenge 4045.3 (4126.5) -> 4042.6 (4144.5) MB, 805.2 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10ea3ea25 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x10d7340f9 node::Abort() [/usr/local/bin/node]
 3: 0x10d73426f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10d8b5787 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x10d8b5723 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x10da56e05 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x10da5578c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10da62030 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0x10da620b1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10da2f147 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
11: 0x10dde6d4e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x10e190819 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
[1]    35655 abort      yarn
deleteme commented 1 year ago

I encountered this same error upgrading packages that also had a resolutions entry in package.json. I was able to work-around the error by removing the resolutions and trying again.

lossen commented 1 year ago

Same issue FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory Neither yarn cache clean nor export NODE_OPTIONS=--max_old_space_size=8192 doesn't help.

obayit commented 1 year ago

I think that this happened to me just after clearing the cache with yarn cache clean

andrewgreenhill commented 1 year ago

I found a solution at https://stackoverflow.com/questions/57923800/yarn-build-in-reactjs-allocation-failed-javascript-heap-out-of-memory

kesha-antonov commented 1 year ago

I deleted yarn.lock and then ran yarn install and everything installed as expected 🤷‍♂️

HoseinGhanbari commented 1 year ago

I added the yarn.lock which was generated by another machine and the heap error was resolved.

volodymyr-borysov commented 2 months ago

have the same error. Upgrading EXPO version to 51v. even export NODE_OPTIONS=--max-old-space-size=8192 && yarn install doesn't help.

I was about to solve be deleting yarn.lock and run yarn install

BUT this way is not 100% correct. After deleting yarn.lock a lot of versions of dependencies changed, it is not what I need

Any possible solutions?