create-react-app RangeError: Maximum call stack size exceededat Object.mkdirSync
Asked Answered
B

6

7

Today I tried to create new react app using (create-react-app app-name) in CMD and this error appeared :

PS C:\Users\ahmed\Desktop\My File\New Folder\New Folder JS\New Folder> create-react-app testing-app
C:\Users\ahmed\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:49
          throw err0
          ^
RangeError: Maximum call stack size exceeded
    at Object.mkdirSync (fs.js:738:10) ...  

Also, the installation will be stuck if I try to install any package in this folder like prop-type, I tried to update my node as well create-react-app but nothing change. I solved this problem by creating my react app in C:\Users\ahmed not in C:\Users\ahmed\Desktop\My File\New Folder\New Folder JS\New Folder
So my question is: why I can't create react app in a long path like C:\Users\ahmed\Desktop\My File\New Folder\New Folder JS\New Folder why it needs to be created in C:\Users \username?

Bridegroom answered 18/3, 2019 at 21:3 Comment(2)
This might be what you're looking forNertie
refer this reference #20936986 exceededAtaraxia
B
7

I find the solution to my problem.
my problem was I tried to creating new react app using npm create-react-app app-name in CMD.
If I try to create react in C:\Users\user-name\ it will install all the packages and react app will work. But in my case, I tried to create react in different location C:\Users\user-name\folder\folder\folderand shows the above error.
I find many solutions most of them tried to edit npmrc file in C:\Program Files\nodejs\node_modules\npm, add or delete same confg in this file. but nothing works !!!
when I create react app the error shows in CMD but at the same time windows defender show this message

unathorised changes blocked
controlled folder access blocked C:\program\File...\node.exe from making changes to the folder C:\Users\user-name\folder\folder\folder

So, the solution was is to stop windows defender and create-react-app works in any location. you can stop windows defender by using different methods stop Windows defender. in my case, I stop Real-time protection, you can do that in windows 10:
settings > update & Security > windows security > virus & threat protection > virus & threat protection settings > Real-time protection "off".
But the best solution is to add node app as trust app in Windows defender settings or disable controlled folder access, you can do that by following this link Use controlled folder access

Bridegroom answered 23/3, 2019 at 8:7 Comment(0)
C
1

Please try to clear npm cache. Using following command.

npm cache clean --force
Capillary answered 24/7, 2019 at 6:24 Comment(0)
S
1

The above problem can be solved using the following approach:

  • If you're on windows, turn off windows defender and then retry create-react-app command. Mostly this should work. If the above solution doesn't work go for the next step.

    • Clear NPM cache by using the following command:

    npm cache clean --force

Now, again retry create-react-app command. This worked like magic for me.

Sexdecillion answered 1/4, 2020 at 14:47 Comment(0)
H
1

I had same problem It comes from windows defender and firewall . So add node.exe to the exceptions for windows defender and firewall and it may work.

Humidifier answered 9/8, 2020 at 12:41 Comment(0)
E
0

I had the same problem in Ubuntu. I just used sudo create-react-app my-app and everything worked!

Eckel answered 26/5, 2021 at 14:12 Comment(0)
N
0

Option Resolution

Another reason you might be experiencing this issue specifically on Windows is due to spaces in your file path.

Make sure that your file path does not spaces, only "_" or camelCase.

Good Example

C:\Users\user.name\projects\project_01

Bad Example

C:\Users\user.name\projects\project 01
Nb answered 22/8, 2021 at 6:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.