You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置allowedCommonJsDependencies后ngrx-store-localstorage警告仍存在求助

解决ngrx-store-localstorage的CommonJS依赖警告问题

你遇到的警告是因为ngrx-store-localstorage内部依赖的deepmerge是CommonJS模块,而你之前只把ngrx-store-localstorage加入了允许列表,并没有覆盖它的依赖项。按照下面的步骤修改即可:

  • 修改angular.json中的allowedCommonJsDependencies配置,把deepmerge也添加进去:
    {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        // 保留你原本的其他配置
        "allowedCommonJsDependencies": ["ngrx-store-localstorage", "deepmerge"]
      }
    }
    
  • 如果你有生产环境的单独配置(configurations.production),确认这个配置里没有覆盖allowedCommonJsDependencies,如果有,同样要加入deepmerge。
  • 清理构建缓存后重新执行构建命令:
    ng build --clear-cache
    

这样就能消除这个CommonJS依赖的警告了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 19:02:35