Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Maximum call stack size exceeded' from dotenv-expand on CircleCI using React

I'm trying to build a react app on CircleCI which until recently I've had no issues with. I'm now getting the following error whenever I attempt an npm run build from my circle.yml:

    #!/bin/bash -eo pipefail
npm run build

> [email protected] build /home/circleci/repo
> react-scripts build

/home/circleci/repo/node_modules/dotenv-expand/lib/main.js:8
      var key = match.replace(/\$|{|}/g, '')
                      ^

RangeError: Maximum call stack size exceeded
    at String.replace (<anonymous>)
    at /home/circleci/repo/node_modules/dotenv-expand/lib/main.js:8:23
    at Array.forEach (<anonymous>)
    at interpolate (/home/circleci/repo/node_modules/dotenv-expand/lib/main.js:7:13)
    at /home/circleci/repo/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/home/circleci/repo/node_modules/dotenv-expand/lib/main.js:7:13)
    at /home/circleci/repo/node_modules/dotenv-expand/lib/main.js:14:18
    at Array.forEach (<anonymous>)
    at interpolate (/home/circleci/repo/node_modules/dotenv-expand/lib/main.js:7:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build 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/circleci/.npm/_logs/2018-03-14T20_57_45_719Z-debug.log
Exited with code 1

I've tried adding/re-added dotenv-expand dependencies as well as any environmental variables I'm using on CircleCI but with no luck.

Any suggestions? Thanks.

like image 377
edant92 Avatar asked Mar 14 '18 21:03

edant92


1 Answers

Turns out I'd been importing environmental variables using the same name e.g. REACT_APP_API_KEY_GOOGLE_MAPS=${REACT_APP_API_KEY_GOOGLE_MAPS} . Once I changed the name e.g. REACT_APP_API_KEY_GOOGLE_MAPS=${REACT_APP_API_KEY_GOOGLE_MAPS_EXT} this issue was resolved!

like image 110
edant92 Avatar answered Nov 12 '22 11:11

edant92