Publish to npm.js using GitHub Actions
1. Token to publish in npm.js

Publish to npm.js using GitHub Actions
1. Token to publish in npm.js
To get started, you’ll want to generate a fresh token on NPM. Simply head over to the NPM dashboard, click on the main menu, and select Access token. From there, just hit the Generate new token button and choose Classic Token option.

Give it a name and choose automation:

Make sure to grab your token first, then proceed to copy it. This token is important as it will be utilized as a GitHub secret, as elaborated in the upcoming section.

2. GitHub secret
Save your token securely in a GitHub secret GitHub Actions have the ability to utilize your GitHub secrets, making it the ideal location to store your token!
Navigate to “Settings” -> “Secrets”, then select “New repository secret” to input your NPM Token that you had copied earlier (I’m using NPM_PUBLISH_TOKEN as an example label here).

3. GitHub actions
This workflow should only be executed when you initiate a fresh release on GitHub.
name: Publish to NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies and build
run: npm ci && npm run build
- name: Publish package on NPM.js
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
The process it follows is quite straightforward:
- Check out the code Prepare the Node.js environment (utilizing Node.js 20 in this case)
- Download necessary dependencies and compile the package (if required)
- Release to NPM! This particular step involves the utilization of our NPM_PUBLISH_TOKEN secret to set up the NODE_AUTH_TOKEN environment variable.
Publish release
To get your changes up and running, make sure to create a new release on GitHub.




Once that’s done, your package will be officially published to NPM!!
메타데이터
- post_id
- 5a203d82f4e5
- slug
- publish-to-npm-js-using-github-actions-5a203d82f4e5
- url
- https://medium.com/@andresbitrian/publish-to-npm-js-using-github-actions-5a203d82f4e5
- canonical_url
- https://medium.com/@andresbitrian/publish-to-npm-js-using-github-actions-5a203d82f4e5
- author_url
- https://medium.com/@andresbitrian
- status
- ok
- fetched_at
- 2026-07-24 01:22:17