Angular生产环境构建出现RXJS "ERROR TypeError: Object(...) is not a function"问题求助
Angular 9生产AOT构建后出现
ERROR TypeError: Object(...) is not a function异常 我已经在StackOverflow和其他网站找了各种解决方案,但尝试后都没效果,只好来这里求助了。
情况是这样的:当我执行普通构建命令ng b时,应用完全正常运行;但使用ng b --prod --aot=true命令构建并运行后,控制台抛出了以下异常:
ERROR TypeError: Object(...) is not a function at CG.getAPIURLs (main.f5019b5d20f499feb949.js:1) at new Ou (main.f5019b5d20f499feb949.js:1) at Sn (main.f5019b5d20f499feb949.js:1) at xn (main.f5019b5d20f499feb949.js:1) at Cr (main.f5019b5d20f499feb949.js:1) at br (main.f5019b5d20f499feb949.js:1) at Object.Rr [as createRootView] (main.f5019b5d20f499feb949.js:1) at Kl.create (main.f5019b5d20f499feb949.js:1) at gt.create (main.f5019b5d20f499feb949.js:1) at Di.bootstrap (main.f5019b5d20f499feb949.js:1) ee @ main.f5019b5d20f499feb949.js:1
我当前使用的Angular版本信息如下:
Angular CLI: 9.1.7 Node: 16.10.0 OS: win32 x64 Angular: 9.1.9 ... animations, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, router Ivy Workspace: No Package Version ----------------------------------------------------------- @angular-devkit/architect 0.901.7 @angular-devkit/build-angular 0.901.7 @angular-devkit/build-optimizer 0.901.7 @angular-devkit/build-webpack 0.901.7 @angular-devkit/core 9.1.7 @angular-devkit/schematics 9.1.7 @angular/cli 9.1.7 @angular/http 7.2.16 @ngtools/webpack 9.1.7 @schematics/angular 9.1.7 @schematics/update 0.901.7 rxjs 6.5.5 typescript 3.7.5 webpack 4.42.0
相关的服务代码如下:
import { APIURLType } from './types/apiurl.type'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from '../../../node_modules/rxjs/Observable'; import { of } from '../../../node_modules/rxjs/Observable/of'; import { environment } from './../../environments/environment'; @Injectable() export class APIPathService { public aPIPathURLs: APIURLType; public kind = 'nothing'; public environmentAPI: APIURLType = environment; constructor(public httpClient: HttpClient) { console.log('APIPathURL.service.ts'); } // ends constructor getAPIURLs(): Observable<APIURLType> { console.log('Environment API: ' + this.environmentAPI.rootPath); return of(this.environmentAPI); } // ends getAPIURLs } // ends class APIPathService
现在我完全没头绪,不知道是不是应该直接升级所有依赖项,希望能得到一些解决问题的线索,非常感谢!
TTFN
Tim
内容的提问来源于stack exchange,提问作者Timothy Shenton
相关产品推荐
相关产品推荐

