首页 > 解决方案 > 从 1.0.46 升级到 1.0.47 后带有 Angular (9) 的 ServiceStack 编译错误

问题描述

在我们的 package.json 中,我们用来^声明包引用@servicestack/client。自上次将 ServiceStack 存储库更新到新版本以来,1.0.47我们收到以下错误:

ERROR in ./node_modules/@servicestack/client/dist/index.js
Module not found: Error: Can't resolve 'fs' in 'MyProjectPath...\node_modules\@servicestack\client\dist'
ERROR in ./node_modules/@servicestack/client/dist/index.js
Module not found: Error: Can't resolve 'path' in 'MyProjectPath...\node_modules\@servicestack\client\dist'

如果我们在构建的package.json修复中定义版本@servicestack/client": "1.0.46运行良好

标签: angularservicestack

解决方案


看起来 Angular 的 AOT 编译器仍然对它不在运行时运行的代码进行静态引用评估。v1.0.48 通过使用动态需求分辨率来解决这个问题。

现在可以从@servicestack/clientnpm 上的latest 获得

  "dependencies": {
    "@servicestack/client": "^1.0.48",
  },

推荐阅读