Lerna add 不会添加内部依赖

Jef*_*wrs 3 javascript npm lerna

我正在使用 lerna 来管理 React 组件库。我的一些组件既有来自 npm 注册表的外部依赖项,也有内部依赖项,即存储库中的同级包。

目录结构

我正在尝试使用该lerna add命令将内部依赖项添加到另一个包。具体来说,我想将 Utils、Typography、Link 添加到 HRWrapper。

要添加实用程序,我运行

lerna add Utils --scope=HRWrapper
Run Code Online (Sandbox Code Playgroud)

并收到此错误

lerna notice cli v3.2.1
lerna info versioning independent
lerna WARN No packages found where Utils can be added.
Run Code Online (Sandbox Code Playgroud)

要安装 Typography 我运行

lerna add Typography --scope=HRWrapper
Run Code Online (Sandbox Code Playgroud)

并收到此错误

lerna notice cli v3.2.1
lerna info versioning independent
lerna ERR! Error: 404 Not Found - GET https://registry.npmjs.org/Typography - Not found
lerna ERR!     at res.buffer.catch.then.body (/Users/powje6f/sites/vz-react/node_modules/npm-registry-fetch/check-response.js:104:15)
lerna ERR! lerna 404 Not Found - GET https://registry.npmjs.org/Typography - Not found
Run Code Online (Sandbox Code Playgroud)

我不确定在尝试安装 Utils 时第一个错误意味着什么。但是,出于某种原因,当我尝试添加 Typography 时,它会在 npm 注册表中搜索它。

这是我的 lerna.json

{
  "lerna": "2.10.0",
  "packages": ["packages/**/*"],
  "version": "independent"
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

小智 5

我也遇到过类似的麻烦。你可以试试这个:

lerna add module-1 packages/prefix-*       Adds the module-1 package to the packages in the 'prefix-' prefixed folders
Run Code Online (Sandbox Code Playgroud)
// Utils
lerna add Utils packages/HRWrapper

// Typography
lerna add Typography packages/HRWrapper
Run Code Online (Sandbox Code Playgroud)

这种方式对我有用。

lerna add module-1 --scope=module-2 
Run Code Online (Sandbox Code Playgroud)

我想不能正常工作的原因是:

仅当module-1已经在 NPM 上注册时,它才可用。