Cara Mengatur NPM Version Tanpa Prefix 'v'

2 menit baca.
Tags: GitHubGit

Secara default, npm version membuat git tag seperti v1.2.3. Sebagian tim lebih suka tag polos seperti 1.2.3.

Perilaku ini bisa diubah dengan satu setting config.

Command untuk menghapus prefix v

Jalankan di project kamu:

npm config set tag-version-prefix ""

Setelah itu, npm version patch akan membuat tag berformat 1.2.4, bukan v1.2.4.

Cek hasilnya

  1. bump versi:
npm version patch
  1. lihat git tag terbaru:
git tag --sort=-creatordate | head -n 3

Kamu akan melihat tag angka tanpa v.

Config lokal vs global

Config khusus project:

npm config set tag-version-prefix "" --location=project

Config global di mesinmu:

npm config set tag-version-prefix "" --location=user

Supaya seragam satu tim, config level project biasanya lebih aman.

Catatan CI dan release

Kalau pipeline release kamu mengharapkan tag v*, perubahan ini bisa merusak otomasi. Cek script CI dulu.

Yang perlu dicek:

  • pattern tag di changelog generator
  • pattern trigger di workflow deploy
  • semantic-release atau script release custom

Command rollback

Kalau mau kembali ke perilaku default:

npm config delete tag-version-prefix

Setelah itu tag kembali ke gaya v1.2.3.