I have an automated deployment tool that generates a React or Angular project, uploads it to Azure App Service, and then restores node_modules to reduce build time.
To avoid running npm install on every deployment, I store a prebuilt node_modules.zip (~60 MB) in Azure Blob Storage.
My workflow is:
Download
node_modules.zipExtract it inside Kudu (App Service console) under
/tmp/...Copy the extracted folder to
/home/site/wwwroot/<project>/node_modules
The problem:
Extracting + copying this ZIP takes more time than running npm install, even though the whole idea was to speed up deployment.
What I tried
Using
node_modules.zipExtracting to
/tmpthen copying to the project directoryTrying different unzip packages (
unzipper,adm-zip, etc.)Using Kudu console and Azure CLI
Issues Observed
Azure App Service file system is slow with thousands of small files
Zip extraction of node_modules is extremely slow
Copying the folder doubles the delay
End result:
npm installactually finishes fasterMy Question
How can I speed up the node_modules restore process on Azure App Service?
I want to avoid running
npm installevery time, but extracting a ZIP ofnode_modulesis even slower. What’s the best practice to quickly restore dependencies on Azure App Service?Additional Notes
App Service is Linux-based
Deployment tool is using Node.js
React and Angular builds are working, this issue is only with node_modules restore
I am open to alternatives like tar.gz, npm cache, npm ci, etc.
What I am looking for
Better format to store
node_modules(tar.gz?)Faster extraction method
Extract directly to destination without copy?
Alternative approaches (npm cache or npm ci)
Any best practices for dependency restore in Azure App Services