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

Angular项目执行ng new后npm install失败,报错ENOENT求助

Troubleshooting npm Install Failure with Angular Project

Hey there, I feel your pain—this ENOENT rename error when running npm install for an Angular project is such a frustrating roadblock, especially after you’ve already tried all the usual fixes. Let’s dive into some targeted solutions that might get you past this:

  • Clean up residual files manually
    The error points to a failed rename of the typescript folder, which often means there’s a corrupted or leftover file blocking the process. Follow these steps:

    1. Delete your entire node_modules folder
    2. Delete package-lock.json (it’ll get regenerated automatically later)
    3. Navigate to D:\Project\FrontEnd\node_modules\@angular-devkit\build-optimizer\node_modules and check for a .typescript.DELETE file—if it exists, delete it manually
    4. Run npm install again
  • Shorten your project path
    Windows has a default maximum path length limit, and your current directory path might be hitting that threshold. Try moving your project to a shorter location, like D:\Proj\AngularApp instead of D:\Project\FrontEnd, then re-run npm install.

  • Use npm ci instead of npm install
    npm ci installs dependencies strictly from the package-lock.json file, skipping any cached or partial installs that could be causing conflicts. Run this command:

    npm ci
    

    (Note: This will automatically delete your node_modules folder before starting the fresh install)

  • Verify folder permissions
    Make sure your user account has full read/write access to your project folder. Right-click the folder → Properties → Security tab → Confirm your user has "Full Control" permissions. If not, add this permission and try the install again.

  • Upgrade Node.js and npm
    Your current versions (Node v8.10.0, npm 5.6.0) are quite outdated, and newer Angular CLI versions often have compatibility issues with older runtime environments. Try upgrading to a LTS version of Node.js (like v16.x or v18.x)—this will come with a newer, more stable npm version. After upgrading:

    1. Uninstall the global Angular CLI: npm uninstall -g @angular/cli
    2. Clear the npm cache: npm cache clean --force
    3. Reinstall the latest Angular CLI: npm install -g @angular/cli
    4. Create a new project and run npm install again
  • Switch to a mirror npm registry
    Sometimes network glitches or registry inconsistencies can cause partial, corrupted downloads. Try using a mirror registry like npmmirror:

    npm install --registry=https://registry.npmmirror.com
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 03:44:46