diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-06-08 02:27:25 +0300 |
---|---|---|
committer | Kat Marchán <kzm@sykosomatic.org> | 2017-06-08 03:40:49 +0300 |
commit | 35316cce2ca2d8eb94161ec7fe7e8f7bec7b3aa7 (patch) | |
tree | ed1ac45f043bfad37fd271cfd5a17b28075fb633 | |
parent | 4100d47ea58b4966c02604f71350b5316108df6a (diff) |
deps: ignore npa.resolve error from parsing peerDeps (#17005)
This emulates npm@4's behavior of simply marking the peerDep
as invalid, instead of crashing.
Fixes: #16981
PR-URL: https://github.com/npm/npm/pull/17005
Credit: @zkat
-rw-r--r-- | lib/install/deps.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js index ec50b1421..e213734a6 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -625,7 +625,10 @@ var validatePeerDeps = exports.validatePeerDeps = function (tree, onInvalid) { if (!tree.package.peerDependencies) return Object.keys(tree.package.peerDependencies).forEach(function (pkgname) { var version = tree.package.peerDependencies[pkgname] - var match = findRequirement(tree.parent || tree, pkgname, npa.resolve(pkgname, version)) + try { + var spec = npa.resolve(pkgname, version) + } catch (e) {} + var match = spec && findRequirement(tree.parent || tree, pkgname, spec) if (!match) onInvalid(tree, pkgname, version) }) } |