bhum's avatar
Level 1

NPM install Laravel-Mix gives error: “Maximum call stack size exceeded”

I've been trying to install npm on laravel but it keeps giving "Maximum call stack size exceeded". So i decided to install the modules individually and it all worked except for the Laravel-Mix. I've tried updating NPM , force clear cache ,delete package-log.json,reinstall nodejs but it still keeps giving:

"Maximum call stack size exceeded"

package.json

    "axios": "^0.18",
    "bootstrap": "^4.0.0",
    "cross-env": "^5.1",
    "jquery": "^3.2",
    "laravel-mix": "^4.0.7",
    "lodash": "^4.17.5",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.15.2",
    "sass-loader": "^7.1.0",
    "vue": "^2.5.17"

npm ERR! Maximum call stack size exceeded

How can I fix this problem?

0 likes
2 replies
bobbybouwmann's avatar

Did you try one of the following work arounds?

npm cache clean --force

npm rebuild -g 

rm -rf node_modules &&  npm install
ronaldgevern's avatar

This error is almost always means you have a problem with recursion in JavaScript code, as there isn't any other way in JavaScript to consume lots of stack. Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as the memory that can be allocated for your use is not unlimited.

How to fix it?

Wrap your recursive function call into a -

setTimeout setImmediate or process.nextTick

Also, you can localize the issue by setting a breakpoint on RangeError type of exception , and then adjust the code appropriately.

http://net-informations.com/js/err/range.htm

Please or to participate in this conversation.