You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PACKAGE_MANAGERS.md
+42-6Lines changed: 42 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,9 +79,45 @@ npm run version:major
79
79
80
80
5. Publish package:
81
81
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
+
85
121
86
122
### Using pnpm
87
123
1. Make your changes
@@ -100,9 +136,9 @@ npm run publish:npm
100
136
4. Bump version (choose one):
101
137
102
138
````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
0 commit comments