Angular Ivy: TypeError: record.factory is not a function
See original GitHub issue🐞 bug report
Affected Package
core.js
Is this a regression?
Yes, it works when I set “enableIvy”: false, But does not work with: “enableIvy”: true,
Description
This is a runtime error, there is no build error. I post this to get help me to get in the right direction to fixing this, and also if anyone else have the same issue after turning on Ivy. At the moment I am clueless.
I have tried many things, to mention a few:
- Found and fixed cyclic dependencies with: npx madge --circular --extensions ts ./
- Turned on these settings and fixed relevant error messages: “fullTemplateTypeCheck”: true, “strictInjectionParameters”: true
🔬 Minimal Reproduction
Sorry I don’t know how to reproduce this outside my own solution. It is a large enterprise solution.
🔥 Exception or Error
Fails in main.ts platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.error(err));
main.ts:18 TypeError: record.factory is not a function
at R3Injector.hydrate (core.js:16747)
at R3Injector.get (core.js:16509)
at core.js:16439
at Set.forEach (<anonymous>)
at new R3Injector (core.js:16435)
at createInjector (core.js:16386)
at new NgModuleRef$1 (core.js:35526)
at NgModuleFactory$1.create (core.js:35629)
at core.js:41676
at ZoneDelegate.invoke (zone-evergreen.js:365)
(anonymous) @ main.ts:18
invoke @ zone-evergreen.js:365
run @ zone-evergreen.js:124
(anonymous) @ zone-evergreen.js:851
invokeTask @ zone-evergreen.js:400
runTask @ zone-evergreen.js:168
drainMicroTaskQueue @ zone-evergreen.js:570
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:553
scheduleTask @ zone-evergreen.js:389
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:841
then @ zone-evergreen.js:967
bootstrapModule @ core.js:41741
./src/main.ts @ main.ts:17
__webpack_require__ @ bootstrap:84
0 @ main.ts:18
__webpack_require__ @ bootstrap:84
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.1
Node: 12.11.1
OS: win32 x64
Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.1
@angular-devkit/build-angular 0.900.1
@angular-devkit/build-optimizer 0.900.1
@angular-devkit/build-webpack 0.900.1
@angular-devkit/core 9.0.1
@angular-devkit/schematics 9.0.1
@angular/cli 9.0.1
@ngtools/webpack 9.0.1
@schematics/angular 9.0.1
@schematics/update 0.900.1
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:11 (2 by maintainers)
Top Results From Across the Web
record.factory is not a function error on Angular Javascript page
I was able to use the Inspect tool on Google Chrome and Chrome is saying that record.factory is not a function, the page...
Read more >Typeerror: Record.Factory Is Not A Function In Ionic - ADocLib
You get this error when you try to execute a function that is uninitialized or improperly initialized. It means that the expression did...
Read more >ERROR TypeError: factory is not a function - ionic-v3
I am getting below error in every projects of ionic 2. Also created new project but getting same error.
Read more >Meme Overflow on Twitter: "record.factory is not a function ...
record.factory is not a function error on Angular Javascript page https://stackoverflow.com/questions/60895036/806889…
Read more >A Deep Dive into @Injectable and providedIn in Ivy - Angular ...
The compileInjectable function handles all types of providers: classes with the Injectable decorator with the providedIn property and common ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have encountered the same problem, because
ng update
added @Injectable to my module which was just a container to import/export one of my pipesI had the same problem, but the solution was quite different.
When I triggered the
ng update
command from Angular 8 to 9,@Injectable()
was automatically added to app.module.ts. This generated the “TypeError: record.factory is not a function” error message. Once removed, my app works like a charm.