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

运行ng new project-1时出现Package安装失败及Schematic工作流错误的技术求助

Troubleshooting "Package install failed" When Creating Angular Project

Hey there, sorry to hear you're hitting this snag while trying to spin up a new Angular project! Let's work through some practical fixes that often resolve this error, even after updating Node.js:

  • Clear the npm cache
    Corrupted cache files are a super common culprit here. Run this command to wipe the cache, then retry your project creation:
    npm cache clean --force
    After clearing, give ng new project-1 another go.

  • Update or reinstall Angular CLI
    Mismatched CLI and Node.js versions can break the schematic workflow. First, check your current CLI version with ng version. If it's not up to date:

    1. Uninstall the global CLI: npm uninstall -g @angular/cli
    2. Install the latest stable version: npm install -g @angular/cli@latest
      Note: On Windows, make sure you run Command Prompt as Administrator for these steps to avoid permission issues.
  • Switch to a different package manager
    Sometimes npm struggles with pulling dependencies—give Yarn a shot instead:

    1. Install Yarn globally if you haven't already: npm install -g yarn
    2. Create the project using Yarn: ng new project-1 --package-manager yarn
  • Check network & registry settings
    Network restrictions or slow connections can derail package downloads. Try switching to a faster, more reliable registry (like the npm mirror) with:
    npm config set registry https://registry.npmmirror.com
    Then retry creating the project.

  • Opt for manual project setup
    If the automated schematic keeps failing, build the project step-by-step:

    1. Create a folder and navigate into it: mkdir project-1 && cd project-1
    2. Initialize npm: npm init -y
    3. Install Angular core dependencies: npm install @angular/core @angular/cli
    4. Initialize the Angular project structure: ng init
  • Downgrade Node.js to an LTS version
    While you installed the latest Node.js, cutting-edge versions sometimes have compatibility gaps with Angular. Try switching to an LTS (Long-Term Support) version like 18.x or 20.x—uninstall your current Node.js, download the LTS build from the official site, and reinstall.

If none of these steps work, share the full error output you get when running ng new project-1 (the lines above the "Package install failed" message)—that will help pinpoint exactly what's going wrong.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 19:08:12