来自另一个仓库的 npm 包?

npm package from inside another repo?

相关:Depend on a branch or tag using a git URL in a package.json?

electrode-archetype-react-app npm 包来自另一个包的 git 存储库的子目录:electrode-io/electrodepackages/electrode-archetype-react-app.

  1. 这怎么可能?
  2. 如何挂接到子包的特定分支?

我试过了

npm install electrode-io/electrode#electrode-archetype-react-app/some-branch

但出现以下错误:

fatal: ambiguous argument 'electrode-archetype-react-app': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

然后我尝试了

npm install github:electrode-io/electrode#electrode-archetype-react-app/some-branch
npm install github:electrode-io/electrode -- package/electrode-archetype-react-app#some-branch
npm install github:electrode-io/electrode#some-branch -- package/electrode-archetype-react-app

没有骰子

这是什么黑魔法?

编辑感谢一位眼尖的同事:电极正在使用Lerna,这可能是这个黑魔法的来源

确实是 puppet-master 的 Lerna,并且不可能使用来自 origin 的远程分支。只能使用相对路径在本地完成。