I have upgraded my version from angular 17 to 18.
I am trying to run ng serve
or ng build
and getting the error below.
\app\node_modules\listr2\node_modules\colorette\index.cjs:54 head = string.substring(0, index) + replace, ^
RangeError: Maximum call stack size exceeded at String.substring (<anonymous>) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:54:17) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy(2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32)
Node.js v20.17.0
When I am running the application, the colorette issue should not occur. If I use some old version but there some auto dependencies on new version I can not be modify them.
I have upgraded my version from angular 17 to 18.
I am trying to run ng serve
or ng build
and getting the error below.
\app\node_modules\listr2\node_modules\colorette\index.cjs:54 head = string.substring(0, index) + replace, ^
RangeError: Maximum call stack size exceeded at String.substring (<anonymous>) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:54:17) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy(2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32) at replaceClose (C:\Users\E02973\Desktop\n6 - Copy (2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32)
Node.js v20.17.0
When I am running the application, the colorette issue should not occur. If I use some old version but there some auto dependencies on new version I can not be modify them.
Share Improve this question edited Nov 21, 2024 at 9:15 Jesse 3,6426 gold badges27 silver badges42 bronze badges asked Sep 3, 2024 at 10:55 Rishidev RajputRishidev Rajput 873 bronze badges 11- looks like the package colorette is causing problem with the upgrade have you removed node modules cleared the cache and install everything back again?you can also try upgrading colorette package if an upgrade exist – JSmith Commented Sep 3, 2024 at 11:03
- I have upgraded colorette package , delete node modules and package-lock.json and reinstall node packages . but still getting same error. Because some of colorette packages install by itself with own versions . please help me – Rishidev Rajput Commented Sep 3, 2024 at 12:48
- is colorette mandatory in your project.Your facing the nmp package hell where you are dependent of maitainers – JSmith Commented Sep 3, 2024 at 12:50
- One other soltuion would be to create a fork of colorette and make modifications – JSmith Commented Sep 3, 2024 at 13:12
- If I remove the colorette package from my project But colorette automatically install with another packages. Second one how can I create fork with any dependency. – Rishidev Rajput Commented Sep 3, 2024 at 14:04
3 Answers
Reset to default 6Colorette is not the cause of the error, it's just a tool that helps format the actual errors.
What I did is open node_modules/colorette/index.cjs
and replace the replaceClose
method with this (adding a console.log
)
const replaceClose = (
index,
string,
close,
replace,
head = string.substring(0, index) + replace,
tail = string.substring(index + close.length),
next = tail.indexOf(close)
) => {
console.log(index, string, close, replace);
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
}
This will log tons of messages, but they will be the actual error and not the colorette error.
@Jesse Colorette is the case of error, because it performs multiple replace operation via recursion, so more output produce more stack requirements.
I made PR to solve this issue: https://github./jorgebucaran/colorette/pull/107
Increasing the stack size helped in my case.
node --stack_size=2048 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --port 4200 --configuration=dev