Using yarn and npm for publishing npm packages.
Aug 04, 2019 · 1 min
Setting up the pre-release version for npm package.
If you already have a package in NPM registry and need a per-release to test minor or major updates among fellow
tester then npm has next
tag to achieve this.
Here are those simple steps:
- Update
package.json
file to set a pre-release version. With yarn you can runyarn version
to update version info in package.json file. Pre-release version e.g:2.0.0-rc1, 3.1.5-rc4
- Run
npm publish yourpackage.tgz --tag next
to publish the package under the next tag. For yarn:yarn publish yourpackage.tgz --tag next
- Run
npm install --save [email protected]
to install prerelease package
Unpublish specific version for NPM registry
To remove specific version from npm registry use following command:
npm unpublish [email protected]
yarn unpublish [email protected]
Adding JSDelivr.
To add JSDelivr to distribute package from CDN add following lines in package.json
:
"unpkg": "dist/index.js",
"jsdelivr": "dist/index.js"
Also, it is important to update index.js file location.
Use Library to automate publishing task.
A package call np
can automate a lot of publishing task & has other helpful feature.
Here are simple steps:
npm install --global np
to install it globally.
Run np
on project directory. It will show interactive UI steps to perform publish.