Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pass the buck on package.json parse errors.

  • Loading branch information...
commit 8518923b6527ba82f23d063e94d736760c34973b 1 parent 3e90c99
@isaacs isaacs authored
Showing with 12 additions and 2 deletions.
  1. +9 −1 lib/utils/error-handler.js
  2. +2 −1  lib/utils/read-json.js
  3. +1 −0  npm.js
View
10 lib/utils/error-handler.js
@@ -62,9 +62,17 @@ function errorHandler (er) {
," "+er.script
,"You can get their info via:"
," npm owner ls "+er.pkgname
- ,"There may be additional logging output above."
+ ,"There is likely additional logging output above."
].join("\n"))
break
+ case npm.EJSONPARSE:
+ log.error(["","Failed to parse package.json data."
+ ,"Note that package.json must be actual JSON, not"
+ ,"just a JavaScript object."
+ ,"","This changed in npm 0.3.0, and is not a bug in npm."
+ ,"Tell the package author to fix their package.json file."
+ ,""].join("\n"), "JSON.parse")
+ break
case npm.E404:
log.error(["","Looks like '"+er.pkgid+"' is not in the npm registry."
,"You should bug the author to publish it."
View
3  lib/utils/read-json.js
@@ -71,7 +71,8 @@ function processJsonString (opts, cb) { return function (er, jsonString) {
json = JSON.parse(jsonString)
} catch (ex) {
var e = new Error(
- "Failed to parse json\n"+ex.message+"\n"+jsonString)
+ "Failed to parse json\n"+ex.message)
+ e.errno = npm.EJSONPARSE
if (cb) return cb(e)
throw e
}
View
1  npm.js
@@ -26,6 +26,7 @@ npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}
npm.EPUBLISHCONFLICT = {}
+npm.EJSONPARSE = {}
try {
Please sign in to comment.
Something went wrong with that request. Please try again.