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

Angular 8执行ng build prod报错,Ng2CompleterModule无法解析@angular/http

Angular 8 Production Build Error with Ng2CompleterModule

Hey there, I totally get how frustrating it is to hit these third-party library snags after an Angular version migration! Let's break down what's happening and fix this step by step:

The Root Cause

You’re right that Angular 8 phased out the @angular/http module in favor of @angular/common/http, but the issue isn’t in your own code anymore—it’s with the Ng2CompleterModule you’re using. The version of this library currently in your project still depends on the old @angular/http module, which is why the template compiler is throwing that error even after you removed all references to @angular/http in your code.

Step-by-Step Fixes

Here’s what you can do to resolve this:

  • Upgrade ng2-completer to an Angular 8-compatible version
    First, check the version of ng2-completer in your package.json. The library has specific versions built for Angular 8+—install the latest compatible release with this command:

    npm install ng2-completer@latest
    

    If you want to be precise, you can confirm the exact Angular 8-compatible version by checking the library’s GitHub repository or npm page (usually versions >=5.0.0 work with Angular 8).

  • Temporary workaround (if upgrading isn’t possible immediately)
    If you can’t upgrade the library right now, you can temporarily install the Angular 8 version of @angular/http to satisfy the dependency. Run this command:

    npm install @angular/http@8.2.14
    

    Note: This is just a stopgap—@angular/http is deprecated in Angular 8, so prioritize upgrading ng2-completer as soon as possible to avoid future issues.

  • Double-check for residual references
    Do a quick sweep to make sure there are no leftover imports of @angular/http in your app.module.ts or component files, and that your tsconfig.json/angular.json don’t have any configuration pointing to the old module.

Verify the Fix

After making the above changes, run your production build command again:

node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --aot --prod

This should resolve the template compile error from Ng2CompleterModule.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 07:37:58