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