-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用 pnpm 安装 egg 依赖之后,pnpm dev 时报错,插件找不到 #4739
Comments
+1 |
pnpm 6.0 使用 --shamefully-hoist 是可以的 |
这等于没用 pnpm |
Hello @aidening. Please provide a reproducible example following the instruction. Issues labeled by 如果在 7 天内没有进展会被自动关闭。 |
最小可复现
|
昨天分析了下 pnpm 的那个目录结构,大概知道为啥 egg 会 break 了,它把子依赖提了一级,这样虽然在 require 里面是支持上溯的,但 egg loader 不会有这个行为。 举个例子,yadan-framework 有一个 egg-xx 的插件,在 pnpm 里面的目录是: [email protected]
| - node_modules
|- yadan-framework
|- egg-xx 而不是我们希望的标准的: [email protected]
| - node_modules
|- yadan-framework
| - node_modules
|- egg-xx 我们 loader 里面应该是插件定位的时候,有可能用了 path.resolve 或 fs.exists 啥的,而不是 require.resolve,所以可能找不到。(回头可能要跟着源码跑一下才能确定) 暂时不打算支持(3 里面再看看),先用 |
:( |
eggjs@3提上日程了? |
看了下 egg-core 源码:https://github.com/eggjs/egg-core/blob/master/lib/loader/mixin/plugin.js#L353 差不多就是这段逻辑,粗暴的写法就是 lookupDirs 数组每一个都要再判断下自己的同级目录。 回头找时间优化下,也欢迎有空的同学直接提 PR。 |
重新安装下依赖看看,应该支持了 |
pnpm dev 之后报错:
2021-08-18 00:05:47,902 ERROR 301 nodejs.Error:
Can not find plugin egg-onerror
in "/mnt/e/workspace/front-project/fadog/fadog-portal/portal/node_modules, /mnt/e/workspace/front-project/fadog/fadog-portal/node_modules/.pnpm/[email protected]/node_modules/egg/node_modules, /mnt/e/workspace/front-project/fadog/fadog-portal/portal/node_modules"/mnt/e/workspace/front-project/fadog/fadog-portal/node_modules/.pnpm/[email protected]/node_modules/egg-cluster/lib/agent_worker.js:32
throw err;
^
Error: Can not find plugin egg-onerror
in "/mnt/e/workspace/front-project/fadog/fadog-portal/portal/node_modules,相关环境信息
之前有同学提过类似的问题,我使用
pnpm install --shamefully-hoist
并没有起作用。The text was updated successfully, but these errors were encountered: