`npm version patch` command failing
Asked Answered
M

3

11

I am trying to patch a version of my Angular project using the command - npm version patch but getting an error -

$ npm version patch npm ERR! npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git] npm ERR! (run in package dir) npm ERR! 'npm -v' or 'npm --version' to print npm version (6.4.0) npm ERR! 'npm view <pkg> version' to view a package's published version npm ERR! 'npm ls' to inspect current package/dependency versions

The same command used to work fine earlier and suddenly stopped working. my npm version is 6.4.0.

Mars answered 1/10, 2018 at 19:9 Comment(0)
M
7

I was able to resolve the error by myself. The error was that the patch version was written as 01. i.e. 2018.11.01 instead of 2018.11.1. npm version patch failed without an explanatory message.

Mars answered 1/10, 2018 at 22:50 Comment(0)
F
6

Yes, you're correct the semver version number must be a valid integer from [0-9] inclusively.

For reference, npm uses node-semver as their semver parser to deal with versioning on their end. Also, you mentioned the error failed silently, you need to run your command with the verbose flag to see everything.

For example, if you do a npm version patch --verbose, npm would spit out additional information for why the command failed. You can use the verbose flag on any valid npm command

Hopefully that helps!

Festal answered 1/10, 2018 at 23:32 Comment(0)
C
1

I ran into the same issue with npm v6.14.8 and eventually discovered that I'd forgotten to include the "version" property in my package.json at all! This now works in npm 7.0.9 and later, but the change hasn't been backported to v6, so be sure you haven't left it out if you're still using that.

Capillary answered 21/11, 2020 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.