Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Better error message on engine mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 6, 2011
1 parent 841e212 commit f4f53d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,19 @@ function addNameRange (name, range, cb) {
}

function installTargetsError (requested, data) {
return new Error("Not found: "+data.name+"@'"+requested+"'\n"
+"Valid install targets:\n"
+JSON.stringify(Object.keys(data["dist-tags"])
.concat(Object.keys(data.versions || {}))))
var targets = Object.keys(data["dist-tags"]).filter(function (f) {
return (data.versions || {}).hasOwnProperty(f)
}).concat(Object.keys(data.versions || {}))

requested = data.name + (requested ? "@'" + requested + "'" : "")

targets = targets.length
? "Valid install targets:\n" + JSON.stringify(targets)
: "No valid targets found.\n"
+ "Perhaps not compatible with your version of node?"

return new Error( "No compatible version found: "
+ requested + "\n" + targets)
}

function addNameVersion (name, ver, cb) {
Expand Down

0 comments on commit f4f53d2

Please sign in to comment.