如何通过纱线安装本地path包? 它无法find包

在我的package.json我通过它的相对path指向本地包my-custom-i18n

的package.json

 "dependencies": { "core-js": "^2.4.1", "my-custom-i18n": "./../MyProject.Shared/myproject-i18n", "rxjs": "5.0.0-beta.12", ... } 

npm install正确安装包,但yarn有问题,根本找不到这个包:

纱线输出

 $ yarn yarn install v0.15.1 info No lockfile found. [1/4] Resolving packages... error Couldn't find package "myproject-i18n" on the "npm" registry. info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command. 

我看到它在npmregistry上看起来不在这个包里。

使用本地包装纱线有什么变化吗? 通过本地软件包,我指的是相对path指向的软件包my-custom-i18n

纱线需要前缀file:用于本地包。

相对path:

 yarn add file:./../your-project 

绝对path

 yarn add file:/dev/your-project 

对于你的例子, package.json依赖将被声明如下:

  "my-custom-i18n": "file:./../MyProject.Shared/myproject-i18n", 

这既适用于纱线,也适用于NPM。

与NPM客户端不兼容,Yarn团队意识到并声明支持此行为 – 参考GitHub问题 。

更新:

v0.21.0发布以来, 不需要 file:前缀。 通过修复和更新日志查看请求 。