update the version in package.json without clean git working directory (without a task runner like Gulp)

Viewed 25246

When running a: npm version prepatch I get the error: "Git working directory not clean." And then a list of files that aren't committed yet.

However, I'd like to do this prerelease to test some stuff locally using a private npm registry. Meaning that I don't have to commit the files just yet using Git.

Is it possible to update the version in package.json without clean git working directory?

3 Answers

From the npm version documentation at https://docs.npmjs.com/cli/version:

If run in a git repo, it will also create a version commit and tag. This behavior is controlled by git-tag-version (see below), and can be disabled on the command line by running npm --no-git-tag-version version. It will fail if the working directory is not clean, unless the -f or --force flag is set.

I'm not 100% certain whether you just need --no-git-tag-version, or if you'll also need the --force flag.

Try to commit first

git add . && git commit -am "new version"

and then

npm version patch 
Related