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

Angular中无法安装服务与组件问题求助

Fixing the dryRunSink.commit(...).ignoreElements is not a function Error in Angular CLI 1.6.4

Hey there, sorry you're stuck with this frustrating error while trying to generate components and services! This issue almost always comes down to mismatched dependency versions between your Angular CLI, @angular-devkit packages, and RxJS—especially with older CLI versions like 1.6.4 paired with Node 6. Let's walk through some practical fixes to get you back on track:

Step 1: Clean and Reinstall Angular CLI & Dependencies

First, let's wipe out old cached packages and ensure we have a consistent CLI setup:

  • Delete your node_modules folder and package-lock.json (or yarn.lock if you use Yarn)
  • Uninstall the global Angular CLI:
    npm uninstall -g @angular/cli
    
  • Clear your npm cache to remove any corrupted packages:
    npm cache clean --force
    
  • Install the last stable 1.x CLI version (1.7.4) which fixes several compatibility issues with Angular 5:
    npm install -g @angular/cli@1.7.4
    
  • Reinstall your project dependencies locally:
    npm install
    

Step 2: Match RxJS Version to Angular 5.2.0

Angular 5.2.0 relies on RxJS 5.5.x, and a mismatched RxJS version is often the root cause of the ignoreElements error (since this is an RxJS operator). Force install the correct RxJS version:

npm install rxjs@5.5.11 --save

Step 3: Align @angular-devkit Package Versions

Your current @angular-devkit/schematics (0.0.48) is newer than other devkit packages (like build-optimizer at 0.0.38), creating a version mismatch. Install a version that matches your build-optimizer:

npm install @angular-devkit/schematics@0.0.38 --save-dev

Step 4: Upgrade Node.js (If Possible)

Node 6.12.3 is quite outdated, and while Angular CLI 1.x technically supports it, newer devkit dependencies may have subtle compatibility issues. Upgrading to Node 8.x (the LTS version recommended for Angular 5) can resolve underlying runtime problems. After upgrading Node, repeat Step 1 to reinstall dependencies.

Once you've tried these steps, run your generate commands again:

ng generate component articles
ng generate service articles

This should resolve the ignoreElements error and let you generate components/services as expected.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:15:15