未捕获的TypeError:this.getExtraNgModuleProviders不是函数

时间:2019-06-24 17:49:55

标签: javascript angular angular6 angular7 jit

我正在一个不断在控制台上抛出此错误的存储库中: Uncaught TypeError: this.getExtraNgModuleProviders is not a function

项目在“ ng serve”上可以正常编译,但是在控制台上显示空白页和该错误。我尝试了很多事情,但找不到出路。

我曾尝试卸载和安装@ angular / compiler,但是没有用。问题似乎出在JitCompiler找不到this.getExtraNgModuleProviders

我认为JitCompiler中的功能this.getExtraNgModuleProviders应该是this._getExtraNgModuleProviders而不是compile.js。由于围绕它的所有功能似乎都包含下划线。

更新:

我认为函数名称与它无关,因为其他开发人员可以很好地运行项目,并且它们具有相同的Jit Compiler.js文件。供参考:单击控制台上的错误后,这就是我需要的地方

 function JitCompiler(_metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _ngModuleCompiler, _summaryResolver, _reflector, _compilerConfig, _console, getExtraNgModuleProviders) {
            this._metadataResolver = _metadataResolver;
            this._templateParser = _templateParser;
            this._styleCompiler = _styleCompiler;
            this._viewCompiler = _viewCompiler;
            this._ngModuleCompiler = _ngModuleCompiler;
            this._summaryResolver = _summaryResolver;
            this._reflector = _reflector;
            this._compilerConfig = _compilerConfig;
            this._console = _console;
            this.getExtraNgModuleProviders = getExtraNgModuleProviders;//<- error is pointed here
            this._compiledTemplateCache = new Map();
            this._compiledHostTemplateCache = new Map();
            this._compiledDirectiveWrapperCache = new Map();
            this._compiledNgModuleCache = new Map();
            this._sharedStylesheetCount = 0;
            this._addedAotSummaries = new Set();
        }

所有其他开发人员都具有与我相同的compile.js。

任何帮助将不胜感激。

3 个答案:

答案 0 :(得分:2)

我刚刚执行了以下操作,错误已解决。这是因为您的@ angular / platform-b​​rowser-dynamic版本不兼容。

npm uninstall @angular/platform-browser-dynamic

npm install @angular/platform-browser-dynamic

答案 1 :(得分:0)

我认为您的angular / platform-b​​rowser-dynamic没有更新。像这样在package.json中进行更改;

"@angular/platform-browser-dynamic": "~8.0.0"

删除节点模块并运行“ npm install”。

希望有帮助。

答案 2 :(得分:0)

具有相同的错误消息。我们正在将.net core与angular一起使用。

ng build完美无缺,但是从VS开始,抛出了Uncaught TypeError: this.getExtraNgModuleProviders is not a function异常。

我可以使用我们的仓库的新克隆来解决此问题,可能是VS缓存中的某些问题导致了问题。