11

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

> jobcatcher-web@0.0.1 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! jobcatcher-web@0.0.1 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the jobcatcher-web@0.0.1 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.

edant92
  • 694
  • 8
  • 18
  • I am getting a very similar error since recently. We may need to fill an issue on the project github. – termux Mar 14 '18 at 22:46
  • 1
    I think I've figured out the actual error! I decided to rebuild my project from scratch and noticed that the error only occured when adding my .env.production file into the directory. I'd used environment variables to set some keys e.g. ${REACT_APP_API_KEY_GOOGLE_MAPS} but if I hardcoded the value it worked correctly... I'll raise an issue on the React Github and post a link here. – edant92 Mar 27 '18 at 22:00
  • Ok, ignore my last comment. 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! – edant92 Mar 27 '18 at 23:36

1 Answers1

27

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!

edant92
  • 694
  • 8
  • 18
  • 1
    This worked like a charm! what interests me more is that why was that an issue in the first place? – Ali Abbas Jaffri Sep 08 '20 at 12:05
  • i had defined two variables in env file. `PORT=3003` and `API_SERVER=http://localhost:$PORT` . after removing $PORT from API_SERVER the problem was resolved. `API_SERVER=http://localhost:3003` – Reza Bayat Aug 11 '22 at 09:17