Create a tag for a npm package

May 4, 2024

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 :

{
  "version": "2.1.2-mobile"
}

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

npm publish --tag mobile

Use the tag

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

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

Or manually in your package.json :

{
  "dependencies": {
    "my-module": "2.1.2-mobile"
  }
}