Zygimantas Berziunas Zygimantas Berziunas - 8 months ago 91
Node.js Question

Azure and node js __dirname

Probably it is not specifically related to webpack/memory-fs, but I am getting the

RangeError: Maximum call stack size exceeded
error (see below for a call stack).

I have found out, that
on Azure (webapp) returns
in my situation, while

Is anything can be done from my side to configure node js to return
instead of


How to reproduce:

  1. Clone the

  2. Create new Azure Web App (default settings).

  3. Configure deployment source to use GitHub.

  4. Click
    . It will take 10+ minutes to complete and it will show that the deployment was successful.

  5. Go to Application settings in Azure and change

  6. Go to kudu page and open powershell console.

  7. Execute
    npm cache clean

  8. Check node version by executing
    node -v
    . It should be

  9. On Azure, navigate to

  10. Execute
    npm run build

  11. In console, you should see a lot of errors which indicates that modules can not be resolved.

  12. OPTIONAL. Test
    npm run build
    on your local machine - it should produce
    without errors.

  13. Update
    to include
    context: __dirname
    to fix previous errors.

  14. Execute
    npm run build

  15. In console, you should see the "RangeError: Maximum call stack size exceeded" error.

Update 1

I only tried to set 6.2.2 runtime after adding the second package.json, so the project structure is not the simplest possible. Maybe just setting node to 6.2.2 breaks the build.


I could reproduce your issue following your steps. I found the key point was setting the WEBSITE_NODE_DEFAULT_VERSION to 6.2.2. And I found the webpack task worked fine if the WEBSITE_NODE_DEFAULT_VERSION was under 6.

Please downgrade the setting WEBSITE_NODE_DEFAULT_VERSION to the version under 6 e.g. 5.9.0 if your node.js modules do not need such high version.
And according the package.json of angular2 athttps://github.com/angular/angular/blob/master/package.json, it seems that the angular2 repository requires the node.js version between 5.4 and 6.

Additionally, the web application's root directory on Azure Web Apps is D:\home\site\wwwroot. So if you want to build your frontend project on Azure Web Apps, you need to locate to D:\home\site\wwwroot\wwwroot\mobile-web-app then run npm run build.