esp
esp

Reputation: 7687

Skip pre-commit hook in "npm version" command

npm version commits the change to package.json and creates a tag. Is there a way to prevent commit hook from being executed while using this command?

Upvotes: 19

Views: 12259

Answers (5)

asvinp
asvinp

Reputation: 11

The following worked for me in a Git repo if you're looking for no tag and no commit but just the increment. (Replace patch with major or minor depending on your use case)

npm --no-git-tag-version version patch

Upvotes: 1

Sathiamoorthy
Sathiamoorthy

Reputation: 11580

I tried all the above solutions, nothing worked for me.

the below command works well.

git commit -m "message" --no-verify

Upvotes: 2

faazshift
faazshift

Reputation: 485

Not sure why this functionality didn't exist in npm before, but I contributed it a little while ago, as I needed it myself. It shipped with [email protected]. To use it, set the config option commit-hooks = false in your .npmrc and the underlying git call will not run commit hooks when creating the version commit. If you only want to disable commit hooks on a single versioning, you can run something similar to:

npm version --no-commit-hooks minor

or alternatively:

npm version --commit-hooks false minor

Upvotes: 25

pcnate
pcnate

Reputation: 1774

From the docs

commit-hooks

  • Default: true
  • Type: Boolean

Run git commit hooks when using the npm version command.

If you simply want to allow this one time run the follow

npm version --no-commit-hooks patch|minor|major

To control this permanently, run the following command

npm config set commit-hooks false

Or add this line to your .npmrc file

commit-hooks=false

Upvotes: 2

Dethariel
Dethariel

Reputation: 3614

According to npm cli docs you can skip the generation of a git tag by using

npm --no-git-tag-version version

Upvotes: 15

Related Questions