Reputation: 1628
I am using node 7.10.1 (which has npm 4.2.0). I am running on Windows 7 SP1.
In other projects in the past, I have used the following to rev the version numbers in my package.json:
git add .
git commit - m "reason for change"
npm version patch
This worked seamlessly in 3 other projects I have done.
Now, when I run this on my current project, I get the following error/output:
> npm version patch
npm ERR! npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
npm ERR! (run in package dir)
npm ERR! 'npm -v' or 'npm --version' to print npm version (4.2.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 package.json
is working fine to do all its other tasks (build, install, etc). Despite the indication in the second line of the output shown above, I am running the command in the package directory root level (same directory as package.json
).
Is there something in my package.json that the npm version patch
doesn't like? The error tells me nothing about what is wrong, let alone how to fix it. The local repo copy seems fine. I even deleted and re-cloned it thinking perhaps I had some problem locally, but no change.
All I can see clearly by this error is just npm !ERR
and the rest of the output seems to make no sense. The only things I have globally installed via npm are :
npm list -g --depth=0
C:\Users\myuser\AppData\Roaming\npm
+-- [email protected]
`-- [email protected]
Below is my package.json
in case there is something wrong in it...
{
"name": "MyProject",
"version": "0.01.19",
"description": "My Project",
"productName": "My Project",
"copyright": "Copyright (C) My Company, Inc. All Rights Reserved",
"main": "main.js",
"scripts": {
"build:prod": "set NODE_ENV=production && webpack -p --progress",
"build:dev": "webpack-dev-server --inline --progress --display-error-details",
"build": "rm -rf testDist && tsc",
"start": "electron .",
"pretest": "npm run build",
"//": "test : ./node_modules/.bin/mocha ./ServerSide/test/fileHandler.test.js --reporter spec",
"test": "karma start karma.conf.js",
"posttest": "node_modules/.bin/remap-istanbul -i converage/coverage-final.json -o coverage -t html",
"coverage": "http-server -c-1 -o -p 9875 ./coverage",
"postversion": "git push && git push --tags"
},
"repository": {
"type": "git",
"url": "http://mylocalgitserver.company.com/my-program/my-project-repo.git"
},
"author": "My Company",
"authors": [
"My Project Team"
],
"os": [
"win32"
],
"cpu": [
"ia32",
"x64"
],
"license": "",
"private": true,
"devDependencies": {
"@angular/animations": "4.3.4",
"@angular/common": "4.3.4",
"@angular/compiler": "4.3.4",
"@angular/core": "4.3.4",
"@angular/forms": "4.3.4",
"@angular/http": "4.3.4",
"@angular/platform-browser": "4.3.4",
"@angular/platform-browser-dynamic": "4.3.4",
"@angular/router": "4.3.4",
"@angular/upgrade": "4.3.4",
"@types/deep-diff": "0.0.30",
"@types/jasmine": "2.5.53",
"@types/mocha": "2.2.41",
"electron": "1.7.6",
"gulp": "3.9.1",,
"gulp-if": "2.0.2",
"gulp-jscs": "4.0.0",
"gulp-jshint": "2.0.4",
"http-server": "0.10.0",
"karma": "1.7.0",
"karma-chrome-launcher": "2.2.0",
"karma-webpack": "2.0.4",
"less": "2.7.2",
"less-loader": "4.0.5",
"loader-utils": "1.1.0",
"lodash": "4.17.4",
"mocha": "3.5.0",
"remap-istanbul": "0.9.5",
"rxjs": "5.4.3",
"shelljs": "0.7.8",
"source-map-loader": "0.2.1",
"webpack": "3.5.4",
"webpack-dev-server": "2.7.1",
"yargs": "8.0.2",
"zone.js": "0.8.16"
},
"dependencies": {
"body-parser": "1.17.2",
"cookie-parser": "1.4.3",
"ejs": "2.5.7",
"express": "4.15.4",
"fs-exists-sync": "0.1.0",
"morgan": "1.8.2",
"project-interface-module": "git+http:///mylocalgitserver.company.com/my-program/project-interface-module.git#v2.7.0",
"stream-to-buffer": "0.1.0",
"uuid": "3.1.0",
"valid-filename": "2.0.1",
"validator": "8.0.0",
"yauzl": "2.8.0"
}
}
Upvotes: 1
Views: 2066
Reputation: 1628
(posting an answer that I figured out)
The problem is that I had leading zeros in the version number field.
It turns out that the version field in package.json
cannot have leading zeros in any part of it. Specifically, in my package.json, I had the following:
{
... ... ..
"version": "0.01.19",
... ... ..
}
This is what causes this command
npm version patch
to produce the error:
npm ERR! npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
npm ERR! (run in package dir)
npm ERR! 'npm -v' or 'npm --version' to print npm version (4.2.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 fix is to change the version field in the package.json file to the following:
{
... ... ..
"version": "0.1.19",
... ... ..
}
While it is good that I found the issue, npm
is producing no helpful information when this error occurs. There is literally no way to debug what is happening by the error message produced. This should be changed by npm
. Until then, beware of not allowing leading zeros in your package.json.
Upvotes: 7