asolopovas's avatar

RangeError: Maximum call stack size exceeded, npm run dev

Hi, I am getting an error when I run npm run dev:

npm run dev    
 
> @ dev /var/www/api
> npm run development


> @ development /var/www/api
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/var/www/api/node_modules/webpack-cli/bin/cli.js:93
                                throw err;
                                ^

RangeError: Maximum call stack size exceeded
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:11:22
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
    at /var/www/api/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/var/www/api/node_modules/dotenv-expand/lib/main.js:7:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development 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!     /home/www-data/.npm/_logs/2020-02-26T18_43_56_383Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ 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!     /home/www-data/.npm/_logs/2020-02-26T18_43_56_399Z-debug.log

The error seems to be happening because I use dorcker and use env variables to in my .env file such as APP_URL=${APP_URL}, php detects env variables but when it comes to run node dotenv-expand seems to have a problem with such .env file, does anyone knows how to go around this problem?

0 likes
5 replies
princedacy's avatar

That issue happens when you refer to undefined environment variables in your .env file

example:

APP_STATE=true

IS_LOCAL="${APP_STATTE}" instead of IS_LOCAL="${APP_STATE}"

4 likes
markaldo'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.

Be considerate while calling functions , also dry run is the best practice to prevent them. It's possible to cause infinite recursion in a fully promisified code, too. That can happen if the promises in a chain don't actually perform any asynchronous execution , in which case control never really returns to the event loop, even though the code otherwise appears to be asynchronous. That's when it's useful to wrap your recursive function call into a -

setTimeout setImmediate or process.nextTick

In some programming languages this can be solved with tail call optimization, where the recursion call is transformed under the hood into a loop so no maximum stack size reached error exists.

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

caracolazul@fastmail.com's avatar

this post is about running Laravel's wrapper for webpack. People coming here are not writing node modules. The correct answer is above regarding invalid .env files.

1 like

Please or to participate in this conversation.