1NPM-VERSION(1)                                                  NPM-VERSION(1)
2
3
4

NAME

6       npm-version - Bump a package version
7

SYNOPSIS

9         npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
10
11         'npm [-v | --version]' to print npm version
12         'npm view <pkg> version' to view a package's published version
13         'npm ls' to inspect current package/dependency versions
14

DESCRIPTION

16       Run  this  in a package directory to bump the version and write the new
17       data  back  to  package.json,  package-lock.json,  and,   if   present,
18       npm-shrinkwrap.json.
19
20       The newversion argument should be a valid semver string, a valid second
21       argument  to  semver.inc   https://github.com/npm/node-semver#functions
22       (one of patch, minor, major, prepatch, preminor, premajor, prerelease),
23       or from-git. In the second case, the existing version  will  be  incre‐
24       mented by 1 in the specified field.  from-git will try to read the lat‐
25       est git tag, and use that as the new npm version.
26
27       If run in a git repo, it will also create a  version  commit  and  tag.
28       This  behavior is controlled by git-tag-version (see below), and can be
29       disabled on the command line by running npm  --no-git-tag-version  ver‐
30       sion.   It  will fail if the working directory is not clean, unless the
31       -f or --force flag is set.
32
33       If supplied with -m or --message config option, npm will use  it  as  a
34       commit  message  when creating a version commit.  If the message config
35       contains %s then that will be replaced with the resulting version  num‐
36       ber.  For example:
37
38         npm version patch -m "Upgrade to %s for reasons"
39
40       If  the  sign-git-tag  config is set, then the tag will be signed using
41       the -s flag to git.  Note that you must have a default GPG key  set  up
42       in your git config for this to work properly.  For example:
43
44         $ npm config set sign-git-tag true
45         $ npm version patch
46
47         You need a passphrase to unlock the secret key for
48         user: "isaacs (http://blog.izs.me/) <i@izs.me>"
49         2048-bit RSA key, ID 6C481CF6, created 2010-08-31
50
51         Enter passphrase:
52
53       If  preversion,  version, or postversion are in the scripts property of
54       the package.json, they will be executed as part of running npm version.
55
56       The exact order of execution is as follows:
57
58       1. Check to make sure the git working directory is clean before we  get
59          started.   Your scripts may add files to the commit in future steps.
60          This step is skipped if the --force flag is set.
61
62       2. Run the preversion script. These scripts have access to the old ver‐
63          sion in package.json.  A typical use would be running your full test
64          suite before deploying.  Any files you  want  added  to  the  commit
65          should be explicitly added using git add.
66
67       3. Bump  version  in  package.json  as  requested (patch, minor, major,
68          etc).
69
70       4. Run the version script. These scripts have access to the new version
71          in  package.json  (so  they  can incorporate it into file headers in
72          generated files for example).  Again, scripts should explicitly  add
73          generated files to the commit using git add.
74
75       5. Commit and tag.
76
77       6. Run  the  postversion  script. Use it to clean up the file system or
78          automatically push the commit and/or tag.
79
80
81       Take the following example:
82
83         "scripts": {
84           "preversion": "npm test",
85           "version": "npm run build && git add -A dist",
86           "postversion": "git push && git push --tags && rm -rf build/temp"
87         }
88
89       This runs all your tests, and proceeds only if  they  pass.  Then  runs
90       your  build  script,  and  adds everything in the dist directory to the
91       commit. After the commit, it pushes the new commit and tag  up  to  the
92       server, and deletes the build/temp directory.
93

CONFIGURATION

95   allow-same-version
96       · Default: false
97
98       · Type: Boolean
99
100
101       Prevents throwing an error when npm version is used to set the new ver‐
102       sion to the same value as the current version.
103
104   git-tag-version
105       · Default: true
106
107       · Type: Boolean
108
109
110       Commit and tag the version change.
111
112   commit-hooks
113       · Default: true
114
115       · Type: Boolean
116
117
118       Run git commit hooks when committing the version change.
119
120   sign-git-tag
121       · Default: false
122
123       · Type: Boolean
124
125
126       Pass the -s flag to git to sign the tag.
127
128       Note that you must have a default GPG key set up in your git config for
129       this to work properly.
130

SEE ALSO

132       · npm help init
133
134       · npm help run-script
135
136       · npm help 7 scripts
137
138       · npm help 5 package.json
139
140       · npm help 7 semver
141
142       · npm help 7 config
143
144
145
146
147
148                                  April 2019                    NPM-VERSION(1)
Impressum