How to install package with local path by Yarn? It couldn't find package

前端 未结 1 1235
长情又很酷
长情又很酷 2020-12-12 19:57

In my package.json I\'m pointing local package my-custom-i18n by its relative path:

package.json

"dependencies":          


        
相关标签:
1条回答
  • 2020-12-12 20:32

    Yarn requires prefix file: for local packages.

    For relative path:

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

    For absolute path

    yarn add file:/dev/your-project
    

    For your example, dependency in package.json would be declared as follows:

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

    This works both for Yarn and NPM as well.

    It is incompatibility with NPM client, Yarn team is aware and declared to support this behavior - reference on GitHub issue.

    Update:

    Since v0.21.0 release, file: prefix is not needed. See pull-request with fix and changelog.

    0 讨论(0)
提交回复
热议问题