reactjscmdcreate-react-appnpm-installwindows-defender

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


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?


Solution

  • 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