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.

AOT compiler - Unexpected value 'Ng2DeviceDetector in ng2-device-detector/dist/index.d.ts

See original GitHub issue

I’m getting Unexpected value 'Ng2DeviceDetector in [...]/node_modules/ng2-device-detector/dist/index.d.ts' imported by the module 'AppModule in [...]/app/app.module.ts'. Please add a @NgModule annotation.

while compiling with aot compiler using: ./node_modules/.bin/ngc -p tsconfig-aot.json everything works just fine with regular ts compiler. It this a bug or am I missing something?

my component:

import {Component} from "@angular/core";
import {Device} from "ng2-device-detector";

@Component({
    selector: "device-info",
    template: `
        <div id="deviceInfo">
        </div>
    `
})
export class DeviceInfoComponent{

    constructor(private device: Device) {
        this.test();
    }

    test() {
        console.log(this.device.browser);
        console.log(this.device.browser_version);
        console.log(this.device.device);
        console.log(this.device.isDesktop());
        console.log(this.device.isMobile());
        console.log(this.device.isDesktop());
    }
}

my app.module.ts

[...]
import {Device, Ng2DeviceDetector} from "ng2-device-detector";

@NgModule({
  imports:      [
      [...]
      Ng2DeviceDetector
  ],
  declarations: [
     [...]
      DeviceInfoComponent,
  ],
  providers: [
      [...]
      Device,
  ],
  bootstrap:    [
      CheckoutComponent
  ]
})
export class AppModule {
    constructor(ngCartRedux: NgRedux<ICartState>) {
        ngCartRedux.provideStore(cartStore)
    }
}
  bootstrap:    [
      CheckoutComponent
  ]
})
export class AppModule {
    constructor(ngCartRedux: NgRedux<ICartState>) {
        ngCartRedux.provideStore(cartStore)
    }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
slav-piluscommented, Apr 3, 2017

@sushruth The forked version does solve the issue for me

0reactions
AhsanAyazcommented, Apr 5, 2017

Pull request 7 seems to have resolved this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular2 AoT Compiler Errors · Issue #11262 - GitHub
When I try to compile my project with ngc, it throws the below error: Error: Error encountered resolving symbol values statically.
Read more >
Error: Unexpected value 'undefined' imported by the module
ts file in the root of my app that was exporting my app.component.ts . So I thought I could do the following: import...
Read more >
Ahead-of-time (AOT) compilation - Angular
This allows the compiler to generate a reference to θ0 in the factory without having to know what the value of θ0 contains....
Read more >
Angular and AOT - CODE Magazine
You can compile the app in the browser at runtime. This means that when the application loads, the JIT, or just-in-time compiler, does...
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