You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSTS发布遇EMFILE错误:Angular 5应用部署Azure失败

Fixing "EMFILE: too many open files" Error When Deploying Angular 5 Hero App to Azure via VSTS CI/CD

Let's break down your issue and walk through practical fixes for this deployment error. The EMFILE: too many open files error happens because your deployment process is trying to handle more files than the system allows—looking at your log, it's stuck on a test file in node_modules, which tells me your deployment package is including way more files than it needs to.

Here are the steps to resolve this:

  1. Deploy Only the Angular Production Build Output
    Angular apps only need the contents of the dist folder (generated by ng build --prod) to run on Azure. Right now, it looks like your deployment task is trying to push the entire project directory—including node_modules, test files, and source code.

    • In your VSTS Azure App Service Deploy task, update the Package or folder field to point to $(Build.ArtifactStagingDirectory)/dist (adjust the path if your build outputs to a different subfolder).
    • Double-check your build pipeline: make sure you're running ng build --prod to generate the optimized production build, and only publishing the dist folder as your build artifact.
  2. Clean Up Unnecessary Files in Your Deployment Package
    The error references a .d.ts test file in node_modules—there's no reason to deploy node_modules or test files to Azure.

    • Add a .deployment file to your project root with the following content to tell Kudu to ignore these directories:
      [config]
      project = dist/
      
    • If you're using kuduscript, modify your deployment script to explicitly copy only the dist contents to the Azure web app's wwwroot directory, skipping node_modules, src, spec, etc.
  3. Temporarily Increase File Descriptor Limits (Workaround)
    If you need a quick fix while you adjust your deployment setup, you can add a PowerShell task before your deployment step to increase the maximum open files limit on the Windows build agent:

    fsutil behavior set maxopenfiles 8192
    

    Note: This is a temporary workaround—addressing the root cause (too many files in the deployment package) is the better long-term solution.

  4. Optimize Your Kuduscript Configuration
    Since you added kuduscript and modified scripts, double-check that your deployment logic isn't recursively copying unnecessary directories. Ensure your script targets only the built static assets in dist and skips development dependencies and test files.

Why This Happens

The EMFILE error occurs when the deployment process opens more files than the operating system allows. In your case, the task is trying to process every file in node_modules (which has thousands of files) along with your source code, pushing it over the limit. By trimming down the deployment package to only what's needed (the dist folder), you'll eliminate this error entirely.

内容的提问来源于stack exchange,提问作者user2502794

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:29:58