@rocket.chat/ui-video-conf

52 阅读3分钟

这是一个很好的问题!让我帮您分析一下为什么在 node_modules 中找不到 @rocket.chat/ui-video-conf 这个依赖。

首先让我查看一下这个文件的内容和相关的依赖配置:

Read file: apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopup/TimedVideoConfPopup.tsx 现在让我查看一下项目的依赖配置,看看 @rocket.chat/ui-video-conf 是如何配置的:

Read file: apps/meteor/package.json 让我继续查看依赖部分:

Read file: apps/meteor/package.json 让我查看dependencies部分:

Ran tool 现在让我查看根目录的package.json,了解workspace配置:

Read file: package.json 现在让我查看packages目录,看看ui-video-conf包是否存在:

Ran tool 很好!我看到 ui-video-conf 包确实存在于 packages 目录中。现在让我查看这个包的package.json:

Read file: packages/ui-video-conf/package.json 现在让我查看这个包的源码结构:

Ran tool 让我查看src目录:

Ran tool 让我查看index.ts文件,了解导出了哪些hooks:

Read file: packages/ui-video-conf/src/index.ts 现在让我查看hooks目录:

Ran tool 让我查看hooks的index.ts:

Read file: packages/ui-video-conf/src/hooks/index.ts 现在让我查看VideoConfContext.ts,看看是否在那里定义了这些hooks:

Read file: packages/ui-video-conf/src/VideoConfContext.ts 现在让我查看VideoConfContext的导出:

Ran tool 让我查看VideoConfContext的导出文件:

Read file: packages/ui-video-conf/src/VideoConfContext/index.ts 让我直接查看VideoConfContext目录:

Ran tool 让我查看dist目录,看看构建后的文件:

Ran tool 让我查看构建后的index.d.ts:

Read file: packages/ui-video-conf/dist/index.d.ts 现在让我查看VideoConfContext.d.ts:

Read file: packages/ui-video-conf/dist/VideoConfContext.d.ts 现在让我查看hooks目录的构建后文件:

Ran tool 让我查看hooks的index.d.ts:

Read file: packages/ui-video-conf/dist/hooks/index.d.ts 现在让我查看useVideoConfContext.d.ts:

Read file: packages/ui-video-conf/dist/hooks/useVideoConfContext.d.ts 很好!现在我找到了答案。让我查看一下meteor应用的package.json中是否有这个依赖:

Ran tool 让我直接查看meteor的package.json的dependencies部分:

Read file: apps/meteor/package.json 太好了!现在我找到了答案。让我继续查看是否还有其他相关依赖:

Read file: apps/meteor/package.json 现在我已经完全理解了问题。让我为您详细解释:

为什么在 node_modules 中找不到 @rocket.chat/ui-video-conf 依赖

原因分析

1. 这是一个 Workspace 依赖,不是 npm 包

apps/meteor/package.json 中,您可以看到:

"@rocket.chat/ui-video-conf": "workspace:^"

这里的 workspace:^ 表示这是一个 Yarn Workspace 依赖,而不是从 npm 仓库安装的包。

2. 包的实际位置

@rocket.chat/ui-video-conf 包实际上位于:

packages/ui-video-conf/

这是一个本地开发的包,不是从外部安装的。

3. Yarn Workspace 的工作原理

  • 根目录的 package.json 定义了 workspaces 配置
  • 所有 apps/*packages/* 目录都被视为工作区
  • 当使用 workspace:^ 时,Yarn 会链接到本地的包,而不是安装到 node_modules

验证方法

1. 检查 yarn.lock 文件yarn.lock 中可以看到:

"@rocket.chat/ui-video-conf": "workspace:^"
resolution: "@rocket.chat/ui-video-conf@workspace:packages/ui-video-conf"

2. 检查 node_modules 中的符号链接node_modules/@rocket.chat/ui-video-conf 中应该有一个指向 ../../packages/ui-video-conf 的符号链接。

3. 包的导出内容 从我们查看的代码可以看到,@rocket.chat/ui-video-conf 确实导出了 useVideoConfStartCall 等 hooks:

// packages/ui-video-conf/dist/hooks/useVideoConfContext.d.ts
export declare const useVideoConfStartCall: () => (rid: import("@rocket.chat/core-typings").IRoom["_id"], title?: string) => void;

解决方案

1. 确保使用 Yarn 而不是 npm

# 使用 yarn 安装依赖
yarn install

# 不要使用 npm install

2. 检查工作区配置 确保根目录的 package.json 中有正确的 workspaces 配置:

"workspaces": [
  "apps/*",
  "packages/*",
  "ee/apps/*",
  "ee/packages/*"
]

3. 重新安装依赖

# 清理并重新安装
yarn cache clean
yarn install

总结

@rocket.chat/ui-video-conf 是一个本地开发的包,通过 Yarn Workspace 机制链接到您的项目中。这就是为什么您在 node_modules 中找不到它的原因 - 它实际上是一个指向 packages/ui-video-conf 目录的符号链接。

这种架构允许 Rocket.Chat 团队在同一个代码库中维护多个相关的包,同时保持它们之间的依赖关系。 接口位置 home\Rocket.Chat\apps\meteor\app\api\server\v1\videoConference.ts