question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.1

Is this a regression?

Yes, works fine in Angular 9.1 without IVY enabled

Description

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:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alxhubcommented, Mar 31, 2020

Wow, is our error awful here.

The actual problem is with this code:

static forRoot(): ModuleWithProviders<CoreModule> {
    return <ModuleWithProviders>{
      ngModule: CoreModule,
      providers: [
        ...THIRD_PARTY_PROVIDERS,
      ],
    }
  }

specifically, the <ModuleWithProviders> cast causes this expression to not be understood, which leads to the β€œis not a reference” error.

1reaction
gkalpakcommented, Mar 30, 2020

You generally should be able to use forRoot() (as long as it is typed correctly and the compiler can statically infer the returned NgModule. What does SharedModule.forRoot look like?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found