Home > database >  Need to specify scope twice when adding library from GitHub Packages
Need to specify scope twice when adding library from GitHub Packages

Time:11-18

In our GitHub org, we have a private repository for an internal Node.js library. I've set up an Actions Workflow to build and publish a package to the GPR whenever a release is cut and tagged. Following the docs here, I've scoped the package with our org name and specified the repository and publishConfig values. The package.json file for the library resembles this:

{
    "name": "@org-name/lib-name",
    "version": "1.1.1",
    "repository": "git://github.com/org-name/lib-name.git",
    "publishConfig": {
        "registry": "https://npm.pkg.github.com"
    },

    ...

}

I am encountering a problem when trying to add the library to another project using Yarn. Specifically, when using the yarn add command, I need to specify the scope twice in order for the library to be found, but this also causes further issues (presumably because the second '@' symbol is expected to indicate a version).

In the consuming project, I have added a .yarnrc file with the following entry for the GPR:

"@org-name:registry" "https:/npm.pkg.github.com"

If I then use the command yarn add @org-name/lib-name --verbose, I get the following:

[1/4]            
  • Related