首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ngrx TypeError:无法将未定义的对象转换为对象

Ngrx TypeError:无法将未定义的对象转换为对象
EN

Stack Overflow用户
提问于 2019-07-02 08:05:09
回答 1查看 176关注 0票数 0

在构建角8.0.1应用程序时,我会得到这个错误消息。我的环境如下(Ubuntu 18):

  • 角8.0.1
  • Rxjs 6.5.0
  • Ngrx Core 1.2.0
  • Ngrx商店8.0.1

我正在按以下方式构建该项目:ng build --base-href /dist/checks-gis-ng/ --prod --named-chunks true --output-hashing none --aot true --build-optimizer true

代码语言:javascript
复制
StoreModule.forRoot(appReducers),
    EffectsModule.forRoot(mainEffects),
代码语言:javascript
复制
export interface AppState {
    authState: AuthState,
    routerReducer: fromNgrxRouter.RouterReducerState<routeReducer.RouterStateUrl>;
}

export const appReducers: ActionReducerMap<AppState> = {
    authState: authReducer,
    routerReducer: fromNgrxRouter.routerReducer
};

这段代码来自我的角库。

代码语言:javascript
复制
export interface AuthModuleState {
    authState: AuthState;
}

export interface AuthState extends AbstractData {
    isLoggedIn: boolean
    userData: UserData,
    message: String
}

export const initialAuthState: AuthState = {
    isLoggedIn : false,
    userData : new UserData(),
    message: ''
};

export const reducers: ActionReducerMap<AuthModuleState> = {
    authState: fromAuthReducer.authReducer,
};

const reducer = createReducer(
    initialAuthState,
    on(authActions.loginRequest, (state, { data }) => authReducerFunctions.onLoginRequestEvent(state, data)),
    on(authActions.loginRequestSuccess, (state, { data }) => authReducerFunctions.onLoginRequestSuccessEvent(state, data)),
    on(authActions.loginRequestError, (state, { data }) => authReducerFunctions.onLoginRequestErrorEvent(state, data)),
    on(authActions.logoutRequest, (state, { data }) => authReducerFunctions.onLogoutRequestEvent(state, data)),
    on(authActions.logoutRequestSuccess, (state, { data }) => authReducerFunctions.onLogoutRequestSuccessEvent(state, data)),
    on(authActions.logoutRequestError, (state, { data }) => authReducerFunctions.onLogoutRequestError(state, data)),
    on(authActions.signupRequest, (state, { data }) => authReducerFunctions.onSignupRequestEvent(state, data)),
    on(authActions.signupRequestSuccess, (state, { data }) => authReducerFunctions.onSignupRequestSuccessEvent(state, data)),
    on(authActions.signupRequestError, (state, { data }) => authReducerFunctions.onSignupRequestError(state, data))
);

export function authReducer(state: AuthState | undefined, action: Action) {
    return reducer(state, action);
}

这是控制台的跟踪:

代码语言:javascript
复制
TypeError: can't convert undefined to object main-es2015.f60865f5f16cd035360b.js:1:1223802
nx http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
rx http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
e http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
reduce self-hosted:354
addFeatures http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
Ox http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
n http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
Si http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
qi http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
qi http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
$i http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
create http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1
bootstrapModuleFactory http://localhost/dist/checks-gis-ng/main-es2015.f60865f5f16cd035360b.js:1TypeError: can't convert undefined to object main-es2015.f60865f5f16cd035360b.js:1:1223802

我必须说我不是Ngrx或Angular方面的专家,所以我认为我做错了什么。如有任何帮助,我们将衷心感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-08 07:31:11

对于您提到的依赖项,@ngrx/core应该至少有一个问题。

这是以前ngrx版本中的一个旧包。你得把它移走。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56847941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档