Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected value '...' imported by the module 'AppModule' #13

Closed
geneeblack opened this issue Sep 19, 2016 · 15 comments
Closed

Error: Unexpected value '...' imported by the module 'AppModule' #13

geneeblack opened this issue Sep 19, 2016 · 15 comments
Labels

Comments

@geneeblack
Copy link

Running under Angular 2 release and when adding JsonApiModule to the imports in app.module.ts I get the following error in the browser:

zone.js:129 Uncaught Error: Unexpected value 'NgaModule' imported by the module 'AppModule'

It seems that after I add JsonApiModule to the app imports it invalidates other imports, not sure if this is an issue with this module or the other but I don't have the issue unless I add JsonApiModule to the app imports

@ghidoz
Copy link
Owner

ghidoz commented Sep 19, 2016

Mmm, if it's saying NgaModule maybe you just have a typo in your code, can be? It should be NgModule.

@geneeblack
Copy link
Author

geneeblack commented Sep 19, 2016

that's one of the other imports that I am doing that works when I am not adding JsonApiModule

import { JsonApiModule } from 'angular2-jsonapi';

@NgModule({
  bootstrap: [App],
  declarations: [
    App
  ],
  imports: [ // import Angular's modules
    BrowserModule,
//    JsonApiModule,
    HttpModule,
    RouterModule,
    FormsModule,
    ReactiveFormsModule,
    NgaModule,
    PagesModule,
    routing,
    JsonpModule,
    AngularFireModule.initializeApp(myFirebaseConfig, myFirebaseAuthConfig)
  ],
  providers: [ // expose our Services and Providers into Angular's dependency injection
    ENV_PROVIDERS,
    APP_PROVIDERS
  ]
})

the original source for this project is https://github.com/akveo/ng2-admin development branch

@geneeblack
Copy link
Author

this may not be relevant to the existing committed code on master, since the version installed from

npm install angular2-jsonapi --save

differs significantly from the latest commits here

@ghidoz
Copy link
Owner

ghidoz commented Sep 19, 2016

The last commits on master are very little and are not relevant. The version on NPM is the one tagged with v3.0.0 here.

Maybe you can try to downgrade to v2.0.0 and see if you get the same error.

@geneeblack
Copy link
Author

It seems to have something to do with the providers: [PROVIDERS] declaration in angular2-jsonapi/module.ts (running with the downloaded source from master). If I remove that it does not err. If I then add it to the PROVIDERS declaration in app.module.ts providers and remove the JsonApiModule import it fails in the same way, stepping on other module imports. I don;t see anything obvious in the PROVIDERS reference, but it seems to be the origin of the issue that I am having.

@HennerM
Copy link
Collaborator

HennerM commented Sep 19, 2016

I had the same issue, I think there is some problem with the decorators.

I worked around this by importing the angular2-jsonapi package before all angular packages with import "angular2-jsonapi" in main.ts

@geneeblack
Copy link
Author

That did it, thanks!

@ghidoz
Copy link
Owner

ghidoz commented Sep 19, 2016

It seems to have something to do with the providers: [PROVIDERS] declaration in angular2-jsonapi/module.ts (running with the downloaded source from master). If I remove that it does not err.

Maybe the problem is that the NgaModule uses the same name for exporting providers. I can try to rename it.

@geneeblack
Copy link
Author

I tried doing that with the source I downloaded (I changed PROVIDERS to JSONAPIPROVIDERS). I still had some type of issue going on after the change (same error with the import of other modules) Loading the source higher in the load order worked for now, not sure what the long term fix is.

@GhEllie
Copy link

GhEllie commented Sep 28, 2016

Hi,
I have upgraded my project with the final version of Angular2 and install the latest version of Json-api

when I want to import JsonApiModule in my AppModule, I have the error like this:
Unexpected value 'SharedModule' imported by the module 'AppModule'

here is the full imports part of the app which worked fine without JsonApiModule:
imports: [JsonApiModule,
BrowserModule, ReactiveFormsModule,
SharedModule, UnderDevelopmentModule, MarketReporterModule, routing
],

I am using the latest version of Json-Api :
"angular2-jsonapi": "3.1.1",

@ghidoz
Copy link
Owner

ghidoz commented Sep 28, 2016

I have searched online and it seems to be a problem with the webpack configuration of the Angular CLI:
angular/angular#11438
angular/angular-cli#2291

Are you actually using Angular CLI?

@ghidoz ghidoz changed the title Angular 2.0.0 Error: Unexpected value '...' imported by the module 'AppModule' Sep 30, 2016
@ghidoz ghidoz added the bug label Oct 10, 2016
@Tybot204
Copy link

Tybot204 commented Dec 16, 2016

I am using Angular CLI, Angular 2, and angular2-jsonapi and have encountered a similar error to this on installing:
"Error: Unexpected value '[Object object]' imported by the module 'AppModule'"

Setup:
Angular CLI: 1.0.0-beta.22-1
Angular 2: 2.1.0
Jsonapi: 3.3.0

@ghidoz ghidoz closed this as completed in 8186f8b Dec 17, 2016
@ghidoz
Copy link
Owner

ghidoz commented Dec 17, 2016

The new v3.4.0 should fix everything! Sorry if it took me so long!

Tested with:

  • angular-cli@1.0.0-beta.22-1
  • @angular/*@2.2.3

Please, let me know if it actually fixes.

@Tybot204
Copy link

@ghidoz I am now getting a different error on building modules for the app (ng serve, ng build, etc.):
"Error: JsonApiModule is not an NgModule at AotPlugin.getNgModuleMetadata"

I updated my Angular version number to match what you commented above as well. Should have the same set up as you. I'll try downgrading Angular 2 tomorrow and see if that changes anything.

@Tybot204
Copy link

@ghidoz Ignore me. Somehow the angular2-jsonapi package was removed from my package.json and just wasn't installed when I cleared by node modules cache. Seems to be working great now, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants