IVY: Value at position 4 in the NgModule.imports of AppModule is not a reference
See original GitHub issueπ bug report
Affected Package
Angular 9.1Is this a regression?
Yes, works fine in Angular 9.1 without IVY enabledDescription
Enabling IVY, in 9.1 gives errors.ERROR in src/app/app.module.ts:21:12 - error NG1010: Value at position 4 in the NgModule.imports of AppModule is not a reference: [object Object]
21 imports: [
~
22 BrowserModule,
~~~~~~~~~~~~~~~~~~
...
27 CoreModule.forRoot(),
~~~~~~~~~~~~~~~~~~~~~~~~~
28 ],
~~~
π Your Environment
Angular Version:
Angular CLI: 9.1.0
Node: 12.16.0
OS: win32 x64
Angular: 9.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.22
@angular-devkit/build-angular 0.901.0
@angular-devkit/build-optimizer 0.901.0
@angular-devkit/build-webpack 0.901.0
@angular-devkit/core 9.1.0
@angular-devkit/schematics 9.1.0
@angular/cdk 9.2.0
@ngtools/webpack 9.1.0
@schematics/angular 9.1.0
@schematics/update 0.901.0
rxjs 6.5.4
typescript 3.6.4
webpack 4.42.0
Anything else relevant? tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"paths": {
"@auth/*": [
"src/app/@auth/*"
],
"@core/*": [
"src/app/@core/*"
],
"@shared/*": [
"src/app/@shared/*"
],
"@akita/*": [
"src/app/@akita/*"
]
},
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
}
}
tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts",
"src/main.single-spa.ts"
],
"include": [
"src/**/*.d.ts"
]
}
Works fine without when I set tsconfig
"enableIvy": false
but I want use IVY
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
typescript - "Value at position 4 in the NgModule.imports of ...
"Value at position 4 in the NgModule.imports of MyCommonLibraryModule is not a reference" when importing an Angular 9 library ; β Lincoln Alves....
Read more >value at position 1 in the ngmodule.declarations of ...
I installed ngx-sortablejs inside angular 13 project, and when I'm trying to import it in the appModule as per documentation the following error...
Read more >NgModule FAQ
Import NgModules whose public (exported) declarable classes you need to reference in this module's component templates. This always means importing CommonModuleΒ ...
Read more >Value at position 5 in the NgModule.imports of AppModule ...
Coding example for the question Value at position 5 in the NgModule.imports of AppModule is not a reference (build error Angular2)-angular.js.
Read more >nrwl-nx/community - Gitter
ERROR in [apps/frontend/src/app/app.module.ts - [error NG1010: Value at position 5 in the NgModule.imports of AppModule is not a reference: [object Object].
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
Wow, is our error awful here.
The actual problem is with this code:
specifically, the
<ModuleWithProviders>
cast causes this expression to not be understood, which leads to the βis not a referenceβ error.You generally should be able to use
forRoot()
(as long as it is typed correctly and the compiler can statically infer the returnedNgModule
. What doesSharedModule.forRoot
look like?