GitHub Action failing to find NPM_TOKEN
See original GitHub issueI’m trying to switch from publishing directly to npm (which worked fine) to using GitHub Packages with an organisation scoped package name.
I’ve changed my package name in package.json
, added the necessary publishConfig
e.g.
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
And changed my Action steps to use NODE_AUTH_TOKEN
instead of NPM_TOKEN
as per the docs, but when I merge a branch and trigger the action I get the following warning and the package is never published (though version tags and changelog are updated, so annoyingly it doesn’t flag as a failed run):
✔ success Wrote authentication token string to /home/runner/.npmrc
⚠ warning Error: Failed to replace env in config: ${NPM_TOKEN}
NPM_TOKEN
is set in my repository Secrets on GitHub.
Here’s the Action setup:
name: Publish
on:
push:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
# this check needs to be in place to prevent a publish loop with auto and github actions
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v2
with:
# Needed for branch protection override
token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare repository
run: git fetch --unshallow --tags
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-${{ hashFiles('package-lock.json') }}
- name: Create release
env
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm ci
npm run build
npm run release
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Github Actions step fails to detect packages from private NPM ...
Hello. I'm giving SWA some advanced scenario where I've published a private package on Github Packages Registry in a repo I own, then...
Read more >Releasing from GitHub Actions npm ERR!! code ENEEDAUTH
I have a GitHub action invoke npx multi-semantic-release , passing the github token and npm token env vars. This is all visible here....
Read more >Github Actions: Missing npm's token · Issue #14 · nice-registry ...
The release action is failing due to npm not being able to authenticate the github CI ... fix: create .npmrc using npm token...
Read more >[BUG] Running npm ci in GitHub Actions erroneously uses ...
Push the project to GitHub. Watch the action fail with the following error in the GitHub Actions details page: npm ERR! code E401...
Read more >Invalid format for "pnpm store path" when NPM token is missing
And a GitHub action that installs and caches dependencies using the ... Error: Unable to process file command 'output' successfully.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reviewed, couple of small suggestions but all looks good ☺Thanks again for all your help
I’ve made a PR to improve those docs. Would you mind reviewing #1828?