npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm version hooks order is wrong

What I Wanted to Do

I want to bump package version with git tag and use version hooks.
let’s assume repository doesn’t have any tags yet,
“preversion”: “git tag”,
“version”: “git tag”,
“postversion”: “git tag”

to output:
–> nothing
–> nothing

What Happened Instead

output is:
–> nothing

Reproduction Steps

$ git init

$ npm init -f

// add version hooks to package scripts
“preversion”: “git tag”,
“version”: “git tag”,
“postversion”: “git tag”

// add and commit
$ git add . && git commit -m “initial commit”

// now you can try to bump version
$ npm version patch


Platform Info

$ npm --versions

{ toremove: '1.0.4',
  npm: '6.4.1',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.4',
  openssl: '1.0.2n',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.50',
  zlib: '1.2.11' }

$ node -p process.platform

After short debug I found that npm version is called with ‘silent: false’ by default, as result ‘updatePackage’ function outputs ‘‘v’ + newVersion’ - which looks like exactly as ‘git tag’ output (and that was misleading)

I don’t know if it is correct, but my issue at least is explained and can be closed