Replies: 2 comments
-
Response to Issue #181148How to "npm install" private packages without token?Hi there, Great question! I understand your frustration with token rotation after migrating to OIDC. Let me clarify the current situation and provide some solutions. Understanding the Current LimitationYou're correct that while OIDC works great for publishing packages, installing private npm packages still requires authentication. However, there are ways to minimize the token rotation burden. Solution OptionsOption 1: Use GitHub Actions GITHUB_TOKEN (Recommended)If your private packages are hosted on GitHub Package Registry, you can use the built-in - name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
scope: '@your-org'
- name: Install dependencies
run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Benefits:
Option 2: Use npm Granular Access Tokens (for npm Registry)If you're using the official npm registry, you can use granular access tokens with longer expiration: - name: Setup .npmrc
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install dependencies
run: npm installNote: While this still requires a token, granular tokens are more secure and can be scoped to specific packages. Option 3: GitHub App Authentication (Advanced)For enterprise setups, you can create a GitHub App that generates short-lived tokens: - name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Install dependencies
run: npm install
env:
NODE_AUTH_TOKEN: ${{ steps.generate_token.outputs.token }}Key Points to Remember
Did You Miss Something?No, you didn't miss anything! The authentication requirement for
Additional Resources
Hope this clarifies the situation! Let me know if you need help implementing any of these solutions. Best regards, |
Beta Was this translation helpful? Give feedback.
-
|
There is still the problem if you try to install another npm package within the workflow run. Neither the I don't know why you are able to provide |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Workflow Configuration
Discussion Details
I have now migrated my workflows to GH Actions and OIDC for all of my internal private packages. But I cannot grasp how to "npm install" without using an actual token. The whole point of migrating was to get rid of the token rotation maintenance-hell. I got rid of it for publishing, but it seems as I'm stuck with tokens for npm install, i.e. good old .npmrc but with the added rotation burden.
Did I miss something?
Beta Was this translation helpful? Give feedback.
All reactions