Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

NgModule Import Error #408

Closed
bassrock opened this issue May 8, 2017 · 3 comments
Closed

NgModule Import Error #408

bassrock opened this issue May 8, 2017 · 3 comments

Comments

@bassrock
Copy link

bassrock commented May 8, 2017

I am currently working on upgrading my angular 2 app to angular 4, and I am currently getting stuck with ngrx store.

When using ng serve the browser outputs the following error:
Error: Unexpected value '[object Object]' imported by the module 'AppModule'. Please add a @NgModule annotation.

I know that ngrx store is causing this because I manually edited the outputted vendor file to dump the proper object and it is erroring when it loads StoreModule.

The store is being imported in the AppModule file in the imports array like:
StoreModule.provideStore(reducer),

The reducers file as the following that builds the reducers:

export const baseReducer: ActionReducer<State> = combineReducers(reducers);

/** ENVIRONMENT SETTING **/
const developmentReducer = baseReducer;
const productionReducer = baseReducer;

export function reducer(state: any, action: any) {
  if (environment.production) {
    return productionReducer(state, action);
  } else {
    return developmentReducer(state, action);
  }
}

Am I missing something with he migration to Angular 4?

@dknitrox
Copy link

dknitrox commented Jun 1, 2017

This error I think you can solve it by adding in your external configuration of your server the following
const nodeExternals = require('webpack-node-externals');
.....
....
externals: nodeExternals ()

@bassrock
Copy link
Author

bassrock commented Jun 1, 2017

@dknitrox Where exactly would this go. I am using a pretty base version of what angular 4 cli creates

@robwormald
Copy link
Contributor

Please check this against NgRx v4, and if it’s still an issue, please reopen on https://github.com/ngrx/platform. Thanks!

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

No branches or pull requests

3 participants