DEV Community

Discussion on: Securely Automating npm publish with the New npm Automation Tokens

Collapse
 
luisenmarroquin profile image
Luis Marroquin

How can I use it to publish a package?

Collapse
 
appsparkler profile image
Akash • Edited

I managed to figure this out after some research. I've also written a blog post about it.

Basically:

Step 1

Get a publish token from your account : docs.npmjs.com/creating-and-viewin...

Step 2

Add .npmrc file to your project root with the following contents by replacing your-access-token with the token you got in step 1.

//registry.npmjs.org/:_authToken=your-access-token
Enter fullscreen mode Exit fullscreen mode

Source : docs.npmjs.com/using-private-packa...

Step 3

Bump the version and publish the package

npm version patch # to bump the version.  You can use major, premajor, minor, preminor, patch or prepatch here depending on your changes.
npm publish --access public # to publish the package
Enter fullscreen mode Exit fullscreen mode