Uncaught TypeError: this.getExtraNgModuleProviders is not a function

Viewed 2903

I am working on a repository that keeps throwing this error on the console: Uncaught TypeError: this.getExtraNgModuleProviders is not a function.

The projects compiles fine on "ng serve" but it shows a blank page and that error on the console. I have tried many things but I couldn't find a way out.

I have tried uninstalling and installing @angular/compiler but didn't work. The problem seems to be with JitCompiler not finding this.getExtraNgModuleProviders

I think the function this.getExtraNgModuleProviders in the JitCompiler should be this._getExtraNgModuleProviders instead on the compiler.js. Since all the functions around it seem to include the underscore.

UPDATE:

I don't think the function name has anything to do with it since other developers can run the project fine and they have the same Jit compiler.js file. For reference: This is where it takes me when I click the error on the console

 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();
        }

All other developers have the same compiler.js as mine.

Any help will be appreciated.

3 Answers

I just did the following and the error was resolved. It is because of version incompatibility of your @angular/platform-browser-dynamic.

npm uninstall @angular/platform-browser-dynamic

npm install @angular/platform-browser-dynamic

I think your angular/platform-browser-dynamic not updated. Change in your package.json like this;

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

after delete node modules and run "npm install" .

Hope it helps.

Had the same error message. We are using .net core with angular.

ng build worked flawless, however starting from VS threw the Uncaught TypeError: this.getExtraNgModuleProviders is not a function exception.

I could fix this with a new clone of our repo, probably something in the VS cache caused the issue.

Related