cnpm / cnpmcore

Private NPM Registry for Enterprise
https://npmmirror.com
MIT License
620 stars 84 forks source link

@eggjs/tegg 相关包升级导致项目无法正常启动,cnpmcore 也无法降级锁 tegg 版本 #640

Open nxps opened 10 months ago

nxps commented 10 months ago

cnpmcore 版本: 3.51.0 tegg 版本: 3.29.0

相关 issue https://github.com/eggjs/tegg/issues/183

nxps commented 10 months ago

demo 项目 https://github.com/nxps/cnpmcore-demo

fengmk2 commented 10 months ago

https://github.com/cnpm/cnpmcore/blob/08678c70db1c1b5425ee713bbccbe5c395e98b3a/app/repository/SearchRepository.ts#L34

这里引入了 searchAdapter

2024-01-16 20:58:47,540 ERROR 48323 framework.EggPrototypeNotFound: Object searchAdapter not found in LOAD_UNIT:cnpmcoreRepository [ https://eggjs.org/zh-cn/faq/TEGG_EGG_PROTO_NOT_FOUND ]
    at EggPrototypeFactory.getPrototype (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/factory/EggPrototypeFactory.ts:45:48)
    at EggPrototypeBuilder.tryFindDefaultPrototype (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/impl/EggPrototypeBuilder.ts:67:41)
    at EggPrototypeBuilder.findInjectObjectPrototype (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/impl/EggPrototypeBuilder.ts:97:19)
    at EggPrototypeBuilder.build (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/impl/EggPrototypeBuilder.ts:117:26)
    at create (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/impl/EggPrototypeBuilder.ts:62:20)
    at Function.createProto (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/factory/EggPrototypeCreatorFactory.ts:48:21)
    at ModuleLoadUnit.init (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/impl/ModuleLoadUnit.ts:184:55)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Function.createLoadUnit (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-metadata@3.29.0/node_modules/@eggjs/tegg-metadata/src/factory/LoadUnitFactory.ts:33:7)
    at async EggModuleLoader.loadModule (/private/tmp/cnpmcore-demo/node_modules/.store/@eggjs+tegg-plugin@3.29.0/node_modules/@eggjs/tegg-plugin/lib/EggModuleLoader.ts:44:24)
code: TEGG_EGG_PROTO_NOT_FOUND
serialNumber: EGG_PROTO_NOT_FOUND
errorContext: ""
pid: 48323
killagu commented 10 months ago

https://github.com/nxps/cnpmcore-demo/blob/main/config/module.json#L6 这里的 infra 模块没提供 SearchAdapter 的实现了。如果你没有相关的基础设施可以给一个空实现的。

nxps commented 10 months ago

https://github.com/nxps/cnpmcore-demo/blob/main/config/module.json#L6 这里的 infra 模块没提供 SearchAdapter 的实现了。如果你没有相关的基础设施可以给一个空实现的。

已修复,抱歉没有仔细看 cnpmcore 发布版本日志,看错误直观感受是 tegg 导致的

nxps commented 10 months ago

还有一个问题,固定版本后运行报错。在半年前,我记得是用当时最新版本(tegg v3.12.0, cnpmcore v3.38.2)开发的,运行正常。

package.json 如下:

    "@eggjs/tegg": "3.12.0",
    "@eggjs/tegg-aop-plugin": "3.12.0",
    "@eggjs/tegg-config": "3.12.0",
    "@eggjs/tegg-controller-plugin": "3.12.0",
    "@eggjs/tegg-eventbus-plugin": "3.12.0",
    "@eggjs/tegg-orm-plugin": "3.12.0",
    "@eggjs/tegg-plugin": "3.12.0",
    "@eggjs/tegg-schedule-plugin": "3.12.0",
    "cnpmcore": "3.38.2",

启动错误如下:

nodejs.ERR_PACKAGE_PATH_NOT_EXPORTEDError: [egg-core] load file: /Users/nxps/github/cnpmcore-demo/node_modules/@eggjs/tegg-orm-plugin/app.js, error: Package subpath './src/setup_hooks' is not defined by "exports" in /Users/nxps/github/cnpmcore-demo/node_modules/leoric/package.json
hezhengxu2018 commented 9 months ago

看着像依赖间版本的问题。固定版本不是适合这个项目的开发方式。package.json不会指明实际依赖所需的最低版本,所以如果更新了代码需要删除lock文件重新安装。我觉得和我曾经碰到的 #382 是类似的问题