question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to install/publish packages from multiple `@scope` and multiple registers?

See original GitHub issue

How to install packages from multiple @scope and multiple registers? I have settings .npmrc in the root of the project:

@scope1:registry=https://npm.pkg.github.com
@scope2:registry=https://npm.pkg.github.com
@scope3:registry=https://npm.anysite.org
@scope4:registry=https://registry.npmjs.org

and npmjs.com by default for a public

I need to create something like this settings .npmrc in the home folder before installing:

//npm.pkg.github.com/:_authToken=<TOKEN_A>
//nnpm.anysite.org/:_authToken=<TOKEN_B>
//registry.npmjs.org/@scope4/:_authToken=<TOKEN_C>

or

//npm.pkg.github.com/@scope1/:_authToken=<TOKEN_A1>
//npm.pkg.github.com/@scope2/:_authToken=<TOKEN_A2>
//nnpm.anysite.org/:_authToken=<TOKEN_B>
//registry.npmjs.org/@scope4/:_authToken=<TOKEN_C>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:23
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
IgorNovozhilovcommented, Sep 27, 2019

given this: #49, #52, #53, #64. a the optimal solution would be something like this:

    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-node@v1
      with:
        node-version: 10.x
        npm-registry:
          - registry: 'https://npm.pkg.github.com'
            scope: '@scope1'
            token: '${{secrets.GITHUB_TOKEN}}'
          - registry: 'https://npm.pkg.github.com'
            scope: '@scope2'
            token: '${{secrets.GITHUB_TOKEN_THIRD_PARTY}}'
          - registry: 'https://nnpm.anysite.org'
            token: '${{secrets.ANYSITE_TOKEN}}'
          - registry: 'https://registry.npmjs.org'
            scope: '@scope4'
            token: '${{secrets.NPMJS_TOKEN}}'
    - run: npm install
    - run: npm test
    - run: npm publish

where, npm-registry - written in .npmrc in the home folder, and is used for all subsequent commands GITHUB_TOKEN - access the current organization GITHUB_TOKEN_THIRD_PARTY - may be a Personal access tokens. Or a Organization access tokens. Yeah, that’s really missing on GitHub, but this would be crucial for using third-party packages from a security perspective

This solution would be universal for both installing and publishing packages, including publishing into multiple repositories at once.

4reactions
WtfJokecommented, May 6, 2021

And what is the current workaround (e.g. how do you write your .npmrc file in the action)?

We have a file called .npmrc_ci and then replace the environment variable in the action run.

.npmrc_ci:

always-auth = true
@bar:registry=https://someartifactory.jfrog.io/artifactory/api/npm/public-npm/
@foo:registry=https://someartifactory.jfrog.io/artifactory/api/npm/public-npm/

//someartifactory.jfrog.io/artifactory/api/npm/public-npm/:_authToken=${NODE_AUTH_TOKEN}

This is the workflow step which replaces the variable:

      - name: Prepare npmrc
        run: envsubst  < .npmrc_ci > .npmrc
        env:
          NODE_AUTH_TOKEN: '${{ secrets.NODE_AUTH_TOKEN}}'

I dont think there is an easy fix for that issue. As far as I know its not possible to provide lists as action input variables (only single value/key), see https://github.com/actions/toolkit/issues/184. So you probably end up with some separator which doesnt look nice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publishing npm packages to multiple registries with Github ...
The scope lets you group the packages (e.g. @OWNER/PACKAGE ), it is required for every published package at GPR, while it is optional...
Read more >
Creating and publishing scoped public packages - npm Docs
To share your code publicly in a user or organization namespace, you can publish public user-scoped or organization-scoped packages to the npm registry....
Read more >
Is there any way to configure multiple registries in a single ...
Publish your private npm packages to the local repo. Users now can run a one time setup. npm config set registry https://nexus/content/groups/GROUP.
Read more >
Ubuntu Manpage: npm-scope - Scoped packages
(As of 2015-04-19, the public npm registry does support scoped packages) If you wish, you may associate a scope with a registry; see...
Read more >
Publishing Your First NPM Package into GitHub Packages
GitHub Packages is a registry to publish and share many package ... so we can't publish multiple package scopes using the same organization....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found