Pnpm Changesets Publish npm Packages
Introduction
pnpm Monorepo multi-package project, using changesets to publish npm packages.
Solution
- 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
- Install Changesets
install dependencies
npm install @changesets/cli
- 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
- Upgrade version
npx changeset version
- 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
Comments