Installing private package from Github Package registry using Yarn fails with not authorized

后端 未结 3 2083
走了就别回头了
走了就别回头了 2021-02-08 12:36

This question is related to these. But none of the solutions worked for me.

  • Yarn can't find private Github npm registry
  • Installing private package fro
3条回答
  •  爱一瞬间的悲伤
    2021-02-08 13:09

    The following worked for me in .npmrc

    @mvce-superstars:registry=https://npm.pkg.github.com
    

    Using yarn v2, the following worked for me in .yarnrc.yml:

    npmScopes:
      "mvce-superstars":
        npmAlwaysAuth: true
        npmRegistryServer: "https://npm.pkg.github.com"
    

    Firstly, note the lowercase scope name. This is supposed to be the name of the owner of the repository (MVCE-Superstars) where the package was published, but the name has to be all lower-cased.


    The setup

    Publishing

    • I created a private copy of this hello-world repository.
    • I copied over the above .npmrc OR .yarnrc.yml file into the repoository.
    • Next I logged in using the npm login --registry=https://npm.pkg.github.com/ OR yarn npm login --scope=mvce-superstars command
    • I entered my github user name, and my token (with scopes read:package, write:package, and repo)
    • Finally, I pushed the package to my private repo using npm publish OR yarn npm publish

    Output

    npm notice 
    npm notice 

提交回复
热议问题