Problem with running `ng serve` on a template - javascript

I recently downloaded a template from theme forest on my windows environment. I am on node version 18.12.1 but in order to successfully run npm install without conflicts, I had to downgrade to node version 16.0.0. After successfully installing the packages, I run ng serve and this error came
<--- Last few GCs --->
[16128:000002138BBA2FA0] 617195 ms: Mark-sweep 2019.7 (2088.4) -> 2007.2 (2092.2) MB, 1150.9 / 0.0 ms (average mu = 0.747, current mu = 0.178) allocation failure; scavenge might not succeed
[16128:000002138BBA2FA0] 619219 ms: Mark-sweep 2023.2 (2092.2) -> 2011.6 (2096.2) MB, 2003.7 / 0.0 ms (average mu = 0.487, current mu = 0.010) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF6C8491B7F node_api_throw_syntax_error+203775
2: 00007FF6C8411556 v8::internal::wasm::WasmCode::safepoint_table_offset+63558
3: 00007FF6C84128C2 v8::internal::wasm::WasmCode::safepoint_table_offset+68530
4: 00007FF6C8EB47F4 v8::Isolate::ReportExternalAllocationLimitReached+116
5: 00007FF6C8E9FB52 v8::Isolate::Exit+674
6: 00007FF6C8D21BBC v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124
7: 00007FF6C8D1EDDB v8::internal::Heap::CollectGarbage+3963
8: 00007FF6C8D35013 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099
9: 00007FF6C8D358BD v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93
10: 00007FF6C8D450F3 v8::internal::Factory::NewFillerObject+851
11: 00007FF6C8A36825 v8::internal::DateCache::Weekday+1349
12: 00007FF6C8F51E81 v8::internal::SetupIsolateDelegate::SetupHeap+558193
13: 00007FF6C8F52F4D v8::internal::SetupIsolateDelegate::SetupHeap+562493
14: 00007FF64B24851C
The same error comes when I do the same procedure with the current node version.
any help???
I have added --max-old-space-size=4076 in my system paths as was instructed by how to invcrease node mem size but I still got the same error.
Note that the same template runs on a different mac OS system.
it also followed the same steps I did, downgrading the node version to install the packages successfully.

For this memory size changes and also system has that sufficient RAM. In below reference link you can Node.js default memory support.
https://medium.com/geekculture/node-js-default-memory-settings-3c0fe8a9ba1
Now, you have to change "start" scripts command in package.json of your project. In this I have assigned 8GB RAM (max_old_space_size=8192).
"scripts": {
"ng": "ng",
"start": "node --max_old_space_size=8192 ./node_modules/#angular/cli/bin/ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}

Related

npx create-react-app fatal error: JavaScript heap out of memory

Tried creating a boiler plate for react app using npx create-react-app assessment
D:\React>create-react-app assessment
Creating a new React app in D:\React\assessment.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
[ ........] | reify:color-convert: timing reifyNode:node_modules/jest-validate/node_modules/color-convert Comp
#
# Fatal error in , line 0
# Fatal process out of memory: Zone
#
#
#
#FailureMessage Object: 000000888EBFA4C0[ ........] / reify:color-convert: timing reifyNode:node_modules/jest-s[ ........] / reify:color-convert: timing reifyNode:node_modules/jest-snapshot/node_modules/color-convert Comp
<--- Last few GCs --->
[7756:000001A77FCE9290] 304467 ms: Scavenge 239.7 (274.6) -> 239.1 (274.6) MB, 2.8 / 0.0 ms (average mu = 0.996, current mu = 0.999) allocation failure
[7756:000001A77FCE9290] 306201 ms: Scavenge 239.8 (274.6) -> 239.3 (274.6) MB, 186.4 / 181.9 ms (average mu = 0.996, current mu = 0.999) allocation failure
[7756:000001A77FCE9290] 307086 ms: Scavenge 240.1 (274.6) -> 239.6 (274.6) MB, 3.9 / 0.1 ms (average mu = 0.996, current mu = 0.999) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 00007FF647760366]
1: StubFrame [pc: 00007FF647761333]
2: StubFrame [pc: 00007FF647732BAD]
Security context: 0x0364ad71a299 <JSObject>
3: replace [00000364AD709699](this=0x03c776effa81 <String[175]\: [\x1b[7m \x1b[27m\x1b[90m........\x1b[0m] / reify:color-convert: \x1b[32;40mtiming\x1b[0m \x1b[35mreifyNode:node_modules/jest-snapshot/node_modules/color-convert\x1b[0m Completed in 194645ms>,0x03b334...
FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting assessment/ from D:\React
Above traces are from CMD also tried with Admin rights, but still same issue.
Also tried to clean NPM cache by npm clean cache --force but the issue still persist,
if anybody can help on the same!!
Using node version 12.2.0 and npm version 7.20.0
This answer looks like it might be related.
Although, I'd suggest upgrading your version of NodeJS to the latest of 12.x or up to 14.x if possible first.
You'll also want to make sure you're getting the latest create-react-app as the issue could be with an older version of NodeJS conflicting with create-react-app.
After you've updated things, I'd use npx create-react-app assessments from the create-react-app guide to create your app to see how things go.

FATAL ERROR: JavaScript heap out of memory -- Node v12.18.1 and Nuxt

I am running Node v12.18.1 . When working on my Nuxt app in VSCODE and run the following command:
npm run dev
I get the following error in VSCODE terminal:
i Preparing project for development 03:55:28
i Initial build may take a while 03:55:28
WARN Components directory not found: ~/components/global 03:55:28
√ Builder initialized 03:55:28
√ Nuxt files generated 03:55:28
√ Client
Compiled successfully in 7.13s
√ Server
Compiled successfully in 7.05s
i Waiting for file changes 03:55:36
i Memory usage: 418 MB (RSS: 519 MB) 03:55:36
i Listening on: http://localhost:3000/ 03:55:36
<--- Last few GCs --->
a[13632:000001B66F1CB6E0] 52658 ms: Mark-sweep 2045.4 (2052.6) -> 2043.6 (2054.1) MB, 279.7 / 0.0 ms (+ 255.2 ms in 58 steps since start of marking, biggest step 14.1 ms, walltime since
start of marking 552 ms) (average mu = 0.113, current mu = 0.032) [13632:000001B66F1CB6E0] 53242 ms: Mark-sweep 2046.8 (2054.4) -> 2045.3 (2055.1) MB, 343.8 / 0.0 ms (+ 225.6 ms in 49 steps since start of marking, biggest step 14.3 ms, walltime since start of marking 584 ms) (average mu = 0.070, current mu = 0.025)
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 00007FF68370978D]
Security context: 0x01f57d1008d1 <JSObject>
1: createComponent(aka createComponent) [0000010ED95B7D81] [C:\Users\nickm\Desktop\work\XXX-nuxt\node_modules\vue\dist\vue.runtime.common.dev.js:~3163] [pc=00000332FBDEFF2C](this=0x018e1e2004b1 <undefined>,0x00dd1d2c3d11 <Object map = 0000005DFCD9D4E9>,0x018e1e2004b1 <undefined>,0x01f079a63321 <VueComponent map = 00000322C22283E9>,0x018e1e2004b...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF682AF51EF napi_wrap+114271
2: 00007FF682A9FE66 v8::base::CPU::has_sse+66630
3: 00007FF682AA0C66 v8::base::CPU::has_sse+70214
4: 00007FF6832B522E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF68329D301 v8::SharedArrayBuffer::Externalize+833
6: 00007FF68316983C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
7: 00007FF683174A70 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312
8: 00007FF683171594 v8::internal::Heap::PageFlagsAreConsistent+3204
9: 00007FF683166D93 v8::internal::Heap::CollectGarbage+1283
10: 00007FF683165404 v8::internal::Heap::AddRetainedMap+2452
11: 00007FF68318660D v8::internal::Factory::NewFillerObject+61
12: 00007FF682EECB2F v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1295
13: 00007FF68370978D v8::internal::SetupIsolateDelegate::SetupHeap+546637
14: 00000332FBDEFF2C
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! XXX-nuxt-spa#1.0.0 dev: `nuxt`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the XXXX-nuxt-spa#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XXX\AppData\Roaming\npm-cache\_logs\2020-07-22T08_56_18_678Z-debug.log
NOte: The above error lines AFTER i Listening on: http://localhost:3000/ do not happen until I open a browser and try to view my app via the local server.
Does anyone have any advice on how I can fix this?

JS stacktrace error inside kubernates Pod

I am running a reactJs application in Production mode inside a Kubernetes pod.container runtime is docker.
Pod status is Running but still we don't get UI. Also when I check logs I see the below JS stacktrace error.
To run React application I have given below command
"build": "set max_old_space_size=8192 && webpack --mode production --max_old_space_size=8192 && serve -s dist -l 3000"
The error I see inside pod logs is
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
<--- Last few GCs --->
[114:0x5632d5a724a0] 27622 ms: Scavenge (reduce) 597.8 (600.3) -> 597.3 (600.3) MB, 3.2 / 0.0 ms (average mu = 0.185, current mu = 0.145) allocation failure
[114:0x5632d5a724a0] 27627 ms: Scavenge (reduce) 598.1 (600.3) -> 597.5 (600.6) MB, 2.4 / 0.0 ms (average mu = 0.185, current mu = 0.145) allocation failure
The problem is that --max_old_space_size is MB and according to your question you are passing 8192 but your pod is limited in resources to 1024.
You need to do one of the following:
Change your pod spec to reserve an amount more than 8192.
Change your command to set --max_old_space_size to a value under 1024.
Or change both, but you need to make sure your pod has enough memory
What happens if you just remove both of the max_old_space_size altogether? Do you really need to override this?

"FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory" with npm search

I have just installed npm 3.10.3 and nodejs v6.3.1 on Windows 10 and when I make my first search with npm I got this message after several minutes:
PS C:\Users\ToOoA> npm search express
npm WARN Building the local index for the first time, please be patient
[..................] | : WARN Building the local index for the first time, please be patient
<--- Last few GCs --->
397899 ms: Mark-sweep 937.3 (1256.9) -> 936.7 (1263.9) MB, 642.4 / 0 ms (+ 402.5 ms in 1423 steps since start of marking, biggest step 13.5 ms) [all
ocation failure] [GC in old space requested].
399012 ms: Mark-sweep 936.7 (1263.9) -> 911.2 (1241.1) MB, 1112.5 / 0 ms [allocation failure] [GC in old space requested].
400136 ms: Mark-sweep 911.2 (1241.1) -> 911.2 (1235.1) MB, 1124.0 / 0 ms [last resort gc].
401258 ms: Mark-sweep 911.2 (1235.1) -> 911.1 (1229.1) MB, 1121.6 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000000A2635C9E51 <JS Object>
1: fromString(aka fromString) [buffer.js:194] [pc=000003378855E0D0] (this=000000A263504189 <undefined>,string=00000099AE54CE31 <Very long string[1
96464212]>,encoding=000000A2635D6359 <String[4]: utf8>)
2: from [buffer.js:94] [pc=000003378855DCF6] (this=000002E9C08A5BB1 <JS Function Buffer (SharedFunctionInfo 000000A2635E3899)>,value=00000099AE54C
E31 <Very long string[196464212]>,encod...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
After googling it, I think it may come from files of a previous install of nodejs not deleted, but I cannot find which ones.
Someone have an idea?
Please update to the latest version of npm, where search is now fixed.
npm install -g npm#latest
This is fixed un npm 4.0.1 :
https://github.com/npm/npm/issues/14498
npm -i npm#4.0.1 -g
npm cache clear

UglifyJS Running out of Memory

I'm trying to minify a 24MB JavaScript file, but after about 10 minutes of runtime, the script exits with an error about running out of memory. Are there any flags that can help? I'm running Windows 7 64-bit with 16GB physical memory.
C:\projects\test\js>uglifyjs -o ffmpeg.min.js ffmpeg.js
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
This worked for me:
"scripts": {
"ugly": "node --max_old_space_size=4096 ./node_modules/uglify-js/bin/uglifyjs ffmpeg.js -c -o ffmpeg.min.js"
},

Categories

Resources