1

Nothing happens when I run

npm version minor -m "test"

As a note, there is output if I run npm version without any arguments:

$ npm version
{ 'my-app': '0.7.0',
  npm: '4.2.0',
  ares: '1.10.1-DEV',
  cldr: '30.0.3',
  http_parser: '2.7.0',
  icu: '58.2',
  modules: '51',
  node: '7.10.0',
  openssl: '1.0.2k',
  tz: '2016j',
  unicode: '9.0',
  uv: '1.11.0',
  v8: '5.5.372.43',
  zlib: '1.2.11' }

How am I supposed to use npm-version? I expect it to update the version number in package.json, run the 'version' script that I've specified in the package.json scripts list, and then commit. I can use npm run version to execute the 'version' script that I specified, but how do I run npm-version correctly?

jmilloy
  • 7,875
  • 11
  • 53
  • 86

3 Answers3

3

Not sure what version of npm you are using but in version 3.10.10 the npm version command takes one argument only, see the help page by typing version --help

[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]

These values relate to SemVer http://semver.org/

For example if your package.json was

{
  "name": "adventure-game",
  "version": "1.1.0",
  "description": "Bring back Monkey Island"
}

Then the following commands would cause the version property in the package.json to be updated.

npm version major // version: "2.1.0" 
npm version minor // version: "1.2.0" 
npm version 2.3.4 // version: "2.3.4"
npm version patch // version: "1.1.1"
npm version premajor // version: "2.0.0-0"

and so on...

Peter Grainger
  • 4,539
  • 1
  • 18
  • 22
2

The call will fail (silently) if in a git repo that is not clean. You can force it to succeed with -f or --force.

jmilloy
  • 7,875
  • 11
  • 53
  • 86
0

If you are on windows a new version of nodejs will do the work. If on Linux ubuntu a : Sudo apt-get install npm, will do the work too