AhsanAyaz / ngx-device-detector

An Angular v7+ library to detect the device, OS, and browser details.
https://ahsanayaz.github.io/ngx-device-detector
MIT License
518 stars 101 forks source link

ng build --prod not working #12

Closed philklei closed 6 years ago

philklei commented 7 years ago

I got this error while building with ng build --prod

ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts Module not found: Error: Can't resolve 'ng2-device-detector/ng2-device-detector' in '\src\$$_gendir\app' @ ./src/$$_gendir/app/app.module.ngfactory.ts 27:0-68 @ ./src/main.ts @ multi ./src/main.ts

AhsanAyaz commented 7 years ago

@philklei Are you using v1.0.0 ?

MAhsenArif commented 7 years ago

@AhsanAyaz I can confirm this error does occur with ng build --prod.

cli: 1.0.0 node: 7.8.0 npm 4.2.0

Any way to get this working in prod mode. ?

AhsanAyaz commented 7 years ago

@MAhsenArif The demo link attached with this repository is working in --prod mode. You can check the build pipeline here. Not sure why is it causing issue. I'll still give it a go tonight to see the cause.

MAhsenArif commented 7 years ago

@AhsanAyaz the problem seems to be when it runs with angular 2 packages.

    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1"

I've tried a test prod build with Angular 4 packages:

    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",

and the prod build is successful.

Doesn't really help me though since my project is based on Angular 2. Could you test and see why it doesnt work for Angular 2.

AhsanAyaz commented 7 years ago

@MAhsenArif Sure I will look into it tonight. One strong recommendation would be to update your angular packages as there might be lot of similar issues occurring with other libraries too as you go forward.

AhsanAyaz commented 7 years ago

@MAhsenArif Are you using ng2-device-detector@1.0.0 ?

MAhsenArif commented 7 years ago

@AhsanAyaz Yes the version is ^1.0.0

shalom26 commented 7 years ago

same here working on angular 2 project ,build failed... any solution ?

Coffee-Tea commented 7 years ago

the same problem on Angular 2.4.0. need help :)

frednomoon commented 7 years ago

I'm also having this problem on Angular 2.4.0.

josel82 commented 7 years ago

I'm also having this problem

angular/cli: 1.0.6 node: 8.4.0 os: darwin x64 angular/common: 4.3.6 angular/compiler: 4.3.6 angular/core: 4.3.6 angular/forms: 4.3.6 angular/http: 4.3.6 angular/platform-browser: 4.3.6 angular/platform-browser-dynamic: 4.3.6 angular/router: 4.3.6 angular/cli: 1.0.6 angular/compiler-cli: 4.3.6

louiswilbrink commented 6 years ago

This is working for me -- my project is rather new, about 3 weeks old using Angular CLI and minimal packages.

AhsanAyaz commented 6 years ago

@louiswilbrink thanks for the info.

This seems to be an issue with Angular2.x and seems to work fine with Angular4.x