6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitHub Actions で GitHub Package Registry にあるパッケージをインストールするときに認証エラーが出たときの解決方法 (npm)

Last updated at Posted at 2019-10-18

GitHub Actions で GitHub Package Registry にあるパッケージをnpm installするときに認証エラーが出たときの解決方法を2つまとめました。

Unable to authenticate, need: Basic realm="GitHub Package Registry"とかでずっこけてる人向けです。

ざっくり

setup-nodeを使ったやり方

これが一番簡単NODE_AUTH_TOKENを忘れないように!

workflow.yml
- name: Use Node.js v10
  uses: actions/setup-node@v1
  with:
    node-version: '10.x'
    registry-url: 'https://npm.pkg.github.com/'
    scope: '@owner'
- run: npm ci
  env:
    NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

~/.npmrc に直接書き込む

複数追加するときにはこれが良さそう(?)
ubuntumacはこれで大丈夫だけどwindowsはまた違う(コマンドプロンプトあんまり分からない)

workflow.yml
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
- run: echo "@owner1:registry=https://npm.pkg.github.com/" >> ~/.npmrc
- run: echo "@owner2:registry=https://npm.pkg.github.com/" >> ~/.npmrc

参考

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?