Back

Create a tag for a npm package

Published on mercredi 9 février 2022Updated dimanche 5 mai 20241 min read

Recently, I had a specific need on one of my npm modules for the mobile app of Colisweb.

The latest version of rescript-logger use a GLIB_C version which is not available on our mobile app CI image and I can't change this image, so I didn't had any other choice than downgrade the version.

To do this, I created a npm tag -mobile in which I published the supported version with the CI.

Create a tag

To create a tag, you need to add as suffix the name you want in the version field in of your package.json. For example :

package.json
{
"version": "2.1.2-mobile"
}

When you will publish your module, you will have to specify the tag in the command.

Terminal window
npm publish --tag mobile

Use the tag

In the project requiring the tag, you can add it by an install command :

Terminal window
yarn add my-module@mobile
# or
npm i my-module@mobile

Or manually in your package.json :

package.json
{
"dependencies": {
"my-module": "2.1.2-mobile"
}
}