尝试 link 依赖时,Lerna 失败并显示 404

Lerna fails with 404 when trying to link dependency

我的结构如下:

这两个项目都还没有发布到 npm。

当我 运行 lerna boostrap 我得到:

❯ lerna bootstrap
lerna info version 2.4.0
lerna info versioning independent
lerna info Bootstrapping 2 packages
lerna info lifecycle preinstall
lerna info Installing external dependencies
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: npm install
lerna ERR! npm ERR! code E404
lerna ERR! npm ERR! 404 Not Found: myproj-util@*

我的理解from the docs是当运行宁lerna bootstrap时它应该"check if each dependency is part of the Lerna repo"所以它应该只是符号链接。

所以...为什么它不只是符号链接我的内部依赖项?依赖在packages/下,文件夹名和包名完全匹配。

文档中的这一行提供了提示:

The version of babel-generator in the package.json of babel-core is satisfied by packages/babel-generator, passing for an internal dependency.

即,您的内部包必须符合任何版本限制,否则它们将被视为外部包。

尽管我的依赖是 "myproj-util": "*",但我忘记添加一个版本(任何版本)到 myproj-utilpackage.json。只需添加 version 即可解决问题。即 myproj-util package.json 看起来像:

{
  "name": "myproj-util",
  "version": "0.1.0"
}