You need to enable JavaScript to run this app. Angular 11安装ngxs/devtools-plugin后启动报LifecycleStateManager无'ɵmod'属性错误
优惠活动
大模型
产品
解决方案
定价
更多

Angular 11安装ngxs/devtools-plugin后启动报LifecycleStateManager无'ɵmod'属性错误

异常触发场景

基于Angular 11开发的项目,完成@ngxs/devtools-plugin安装并完成接入配置后,启动应用时触发原因暂未明确的运行时异常,浏览器控制台抛出的完整错误堆栈如下:

core.js:2124 Uncaught Error: Type LifecycleStateManager does not have 'ɵmod' property.
at getNgModuleDef (core.js:2124)
at recurse (core.js:24921)
at recurse (core.js:24932)
at recurse (core.js:24932)
at registerNgModuleType (core.js:24917)
at new NgModuleFactory$1 (core.js:25031)
at compileNgModuleFactory__POST_R3__ (core.js:28586)
at PlatformRef.bootstrapModule (core.js:28824)
at Module.zUnb (main.ts:11)
at __webpack_require__ (bootstrap:79)
问题根因

报错核心是依赖版本生态不匹配:
Angular 11的模块编译流程会遍历所有被纳入NgModule导入数组的类型,读取其内置的ɵmod属性判定该类型是否为合法NgModule。当前安装的@ngxs/devtools-plugin属于适配Angular 14+版本的高版本迭代,其内部导出的LifecycleStateManager是纯运行时服务类,本身不携带NgModule元数据定义,被错误纳入模块解析流程后,框架检测不到对应的ɵmod属性,就会直接抛出运行时错误。

修复操作步骤
  • 卸载当前项目中安装的高版本@ngxs/devtools-plugin,执行命令:npm uninstall @ngxs/devtools-plugin
  • 安装适配Angular 11、和项目现有NGXS核心版本匹配的稳定版依赖,执行安装命令:npm install @ngxs/devtools-plugin@3.7.6 --save
  • 检查项目根模块的NGXS插件配置逻辑,确认没有将插件内部的非模块类(如LifecycleStateManager)误写入NgModule的imports数组
  • 清空项目本地编译缓存后,重新执行启动命令,验证异常是否消除

内容的提问来源于stack exchange,提问作者Mateusz Sobczak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.29 11:54:05