Pnpm Changesets Publish npm Packages

Introduction

pnpm Monorepo multi-package project, using changesets to publish npm packages.

Solution

  1. Log in to your npm account

Confirm the current local registry address

npm config get registry

Just display https://registry.npmjs.org/, if not, use the following command to switch

npm config set registry https://registry.npmjs.org/

Then check the currently logged in npm account

npm whoami

If it is not the account you want, log out

npm logout

Log in to your account again

npm login
  1. Install Changesets

install dependencies

npm install @changesets/cli
  1. Add the package you want to publish
npx changeset

Follow the interactive prompt to select the subpackage you want to publish

D:\code\github\openHacking>npx changeset
๐Ÿฆ‹ Which packages would you like to include? @openHacking/core
๐Ÿฆ‹ Which packages should have a major bump? ยท No items were selected
๐Ÿฆ‹ Which packages should have a minor bump? ยท No items were selected
๐Ÿฆ‹ The following packages will be patch bumped:
๐Ÿฆ‹ @openHacking/core@0.0.1
๐Ÿฆ‹ Please enter a summary for this change (this will be in the changelogs).
๐Ÿฆ‹ (submit empty line to open external editor)
๐Ÿฆ‹ Summary init npm package
๐Ÿฆ‹
๐Ÿฆ‹ === Summary of changesets ===
๐Ÿฆ‹ patch: @openHacking/core
๐Ÿฆ‹
๐Ÿฆ‹ Note: All dependents of these packages that will be incompatible with
๐Ÿฆ‹ the new version will be patch bumped when this changeset is applied.
๐Ÿฆ‹
๐Ÿฆ‹ Is this your desired changeset? (Y/n) true
๐Ÿฆ‹ Changeset added! - you can now commit it
๐Ÿฆ‹
๐Ÿฆ‹ If you want to modify or expand on the changeset summary, you can find it here
๐Ÿฆ‹ info D:\code\github\openHacking\.changeset\rich-tools-pretend.md
  1. Upgrade version
npx changeset version
  1. Publish
npx changeset publish

Release Prerelease

Before releasing the official version, we may need to release the alpha, beta version, or prerelease version, and we need to use the changeset pre command

enter enters Prerelease mode exit exits Prerelease mode

Release Prerelease

yarn changeset pre enter next
yarn changeset version
git add .
git commit -m "Enter prerelease mode and version packages"
yarn changeset publish
git push --follow-tags

Exit Prerelease mode and start releasing release

yarn changeset pre exit
yarn changeset version
git add .
git commit -m "Exit prerelease mode and version packages"
yarn changeset publish
git push --follow-tags

Reference

Comments