Skip to content

Commit ea09a57

Browse files
feat: Enhance publishing instructions with custom tags for npm packages
1 parent 0c44347 commit ea09a57

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

PACKAGE_MANAGERS.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,45 @@ npm run version:major
7979

8080
5. Publish package:
8181

82-
```bash
83-
npm run publish:npm
84-
```
82+
# 📦 Publishing and Installing npm Packages with Custom Tags
83+
84+
When you publish a package to npm, each version **must have a version number higher than all previously published versions**. This helps npm identify the newest version.
85+
86+
If you try to publish a version that is **lower or the same** as a previously published version using the default `latest` tag, npm will throw an error.
87+
88+
---
89+
90+
## Using Custom Tags to Avoid Errors
91+
92+
To avoid this error, you can publish your package using a **different tag** instead of `latest`. Tags let you label versions differently, such as `beta`, `next`, or `dev`.
93+
94+
---
95+
96+
## Example: Publishing a Beta Version
97+
98+
If you're working on a new feature or a major update and want users to test it **without affecting the stable release**, you can publish it under a `beta` tag.
99+
100+
### Steps:
101+
102+
1. **Update the Version**
103+
Increment your package’s version number to indicate it’s a beta release.
104+
For example, if your current version is `1.0.0`, you might update it to `1.1.0-beta.0`.
105+
106+
2. **Publish with a Custom Tag**
107+
Run the following command to publish your package under the `beta` tag:
108+
109+
```bash
110+
npm publish --tag beta
111+
```
112+
113+
Or if you use an npm script like publish:npm:
114+
115+
```bash
116+
npm run publish:npm -- --tag beta
117+
```
118+
119+
This way, your beta version is available for testing, but users installing your package normally will still get the stable latest version.
120+
85121

86122
### Using pnpm
87123
1. Make your changes
@@ -100,9 +136,9 @@ npm run publish:npm
100136
4. Bump version (choose one):
101137

102138
````bash
103-
npm run version:patch
104-
npm run version:minor
105-
npm run version:major
139+
npm run version:patch # Small bugfixes, no new features
140+
npm run version:minor # New features, no breaking changes
141+
npm run version:major # Breaking changes, major updates
106142
````
107143

108144
5. Publish:

0 commit comments

Comments
 (0)