laf icon indicating copy to clipboard operation
laf copied to clipboard

[bug] 安装 app-service 自带依赖的另一版本导致 app-service 启动失败

Open object-kaz opened this issue 2 years ago • 0 comments

复现方法:

  1. 在依赖管理安装 [email protected],再安装一个非自带依赖,如 vue@latest
  2. 重启服务
  3. 查看容器信息,发现 app-service 崩溃了,崩溃日志如下

image

发生这个问题的原因: multerapp-service 启动服务所需要的依赖,当使用依赖管理安装另一个版本的 multer 时,这个另一个版本的 multer 会覆盖原来自带的 multer,导致启动失败。

一些解决方案:

  1. 使用依赖别名,给 app-service 运行需要的依赖全部加上别名
npm install -S laf-internal-multer@npm:multer
  1. 使用 rollup 等打包工具将 app-service 业务代码和所需依赖打包在一起,构建镜像时忽略 node_modules 以及 package.json。
  2. app-service 的核心业务逻辑移动到另外一个包 app-service-engineapp-service 只用来调用 app-service-engine 这个库的函数,这样 app-service 只含有 app-service-engine 这一个依赖。

object-kaz avatar May 29 '22 08:05 object-kaz