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.

Add documentation for GET of private NPM packages

See original GitHub issue

Getting a 404 error when trying to fetch a private NPM package. The NPM_TOKEN is included and used as a secret. Locally I also have this problem sometimes but the issue is resolved by doing a npm login.

workflow:

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - name: Use Node.js v10.x
      uses: actions/setup-node@v1
      with:
        version: 10.x
    - name: npm install, build, and test
      env:
        NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
      run: |
        npm install
        npm run build --if-present
        npm test

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
damccormcommented, Aug 13, 2019

I don’t see any npm docs saying NPM_AUTH_TOKEN is supported. With that said, you can configure auth with this action. There are examples in the README, but in this case you would want:

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - name: Use Node.js v10.x
      uses: actions/setup-node@v1
      with:
        version: 10.x
        registry: 'https://registry.npmjs.org'
    - name: npm install, build, and test
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
      run: |
        npm install
        npm run build --if-present
        npm test

Note the added registry parameter for the action and the change of the env var name to NODE_AUTH_TOKEN.

Without a registry parameter we don’t configure auth by default.

0reactions
jwaltoncommented, Aug 22, 2019

Or, we could add a envKey input to setup-node which defaults to “NODE_AUTH_TOKEN” and then as an end user you could make the variable whatever you wanted!

And, of course, you can always do:

      - name: npm install
        if: success()
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: |
          echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
          npm install

🙃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating and publishing private packages - npm Docs
On the command line, navigate to the root directory of your package. cd /path/to/package ; To publish your private package to the npm...
Read more >
Using private npm packages - Expo Documentation
Learn how to configure EAS Build to use private npm packages. ... The recommended way is to add the NPM_TOKEN secret to your...
Read more >
Installing private npm modules · Gemfury Dev Center
You can use your Registry URL to install packages individually. First, you need to configure npm authentication to enable access to your private...
Read more >
Create Your Own NPM Package — Private or Public - Medium
You were looking for a documentation on how to create your own package in NPM, ... will get to know how can you...
Read more >
Install private packages · Cloudflare Pages docs
In your Pages project's Settings > Environment variables, add a new environment variable named NPM_TOKEN to the Production and Preview ...
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