tb / ng2-nouislider

Angular2 noUiSlider directive
http://tb.github.io/ng2-nouislider/
MIT License
184 stars 114 forks source link

Error: Unexpected value 'NouisliderModule in ... #116

Closed iCodr8 closed 7 years ago

iCodr8 commented 7 years ago

When I am building my project for production the following error is appearing.

Error: Unexpected value 'NouisliderModule in /path-to-project/node_modules/ng2-nouislider/src/nouislider.js' imported by the module 'MyModule in /path-to-project/src/my.module.ts'. Please add a @NgModule annotation.

Has anyone a tip for me? I don't know why this error occurs.

iCodr8 commented 7 years ago

Version 1.7.0

iCodr8 commented 7 years ago

I changed

import {NouisliderModule} from 'ng2-nouislider';

to

import {NouisliderModule} from 'ng2-nouislider/src/nouislider';

and now it is working... But this is not a nice solution. I think there should be added an index.ts that has a reference to the src/nouislider directory.

kikukiks commented 7 years ago

I'm having the same issue. I've just updated my dependencies as well, so my ng -v output looks like this:

@angular/cli: 1.4.2                     
node: 7.10.0                            
os: linux x64                           
@angular/animations: 4.4.1              
@angular/common: 4.4.1                  
@angular/compiler: 4.4.1                
@angular/core: 4.4.1                    
@angular/forms: 4.4.1                   
@angular/http: 4.4.1                    
@angular/platform-browser: 4.4.1        
@angular/platform-browser-dynamic: 4.4.1
@angular/router: 4.4.1                  
@angular/cli: 1.4.2                     
@angular/compiler-cli: 4.4.1            
@angular/language-service: 4.4.1        
typescript: 2.3.4

I haven't been able to solve this for hours. I'm also having problems when I serve the application using ng-serve. It fails the first time, giving me ERROR in Error: NouisliderModule is not an NgModule. Although, when I rebuild, it runs beautifully.

However, building the project with AOT always fails with this:

ERROR in Error: Unexpected value 'NouisliderModule in /path/node_modules/ng2-nouislider/src/nouislider.js' imported by the module 'AppModule in /path/src/app/app.module.ts'. Please add a @NgModule annotation.

These are the issues that I've combed through, but to no avail: https://github.com/angular/angular/issues/15763 https://github.com/angular/angular-cli/issues/3426

kikukiks commented 7 years ago

@iCodr8 This workaround is indeed working. Thank you for that! At least I can continue development until there is an actual fix to the issue.

This seems to be the culprit: https://github.com/tb/ng2-nouislider/issues/113

TVrijdag commented 7 years ago

I think that adding "typings": "src/nouislider.d.ts" to the package.json should fix the issue