RangeError: Maximum call stack size exceeded Error when I run d2 app scripts init my-app

When I run the d2 app scripts init pmtct to create a new app, am getting the following error below.

RangeError: Maximum call stack size exceeded
at Object.existsSync (node:fs:290:20)
at findYarnLock (C:\Users\MY PC\AppData\Local\Yarn\Data\global\node_modules@dhis2\cli-app-scripts\src\lib\paths.js:16:12)


The first thought that I got in mind after reading “findYarnLock” is that it might work if you change the directory where you are running the command to create a new app.

Most importantly before trying any of the commands below if nothing works please mention the yarn and npm versions you are using as well as the environment you are working on.

Some of the following commands have helped me resolve so many of these random errors:
npm update -g -D

npm audit fix then npm install

Try again in a different directory (avoid folders or directories with restrictions) For example, I had issues installing directly to my desktop so when I changed to a folder in C:\my apps\ it worked.

If you do all the above and it still doesn’t work, after you run d2 app scripts init pmtct check again with d2 app scripts init . in the same directory - see what error appears.

Thanks and good luck!

Hello @Gassim Thanks for the support steps. However the above steps didn’t work. I had to delete the findYarnLock function in the path.js file under

C:\Users\MY PC\AppData\Local\Yarn\Data\global\node_modules@dhis2\cli-app-scripts\node_modules.

After deleting that function I was able to create my react app successfully.


Hi @fmwesigwa,
Glad to know you found the solution to this! This is great, and thanks for sharing the solution :+1::+1: