diff --git a/index.js b/index.js
index 70bf590eac735a43af26abf7bb39dc90e5735202..782345bc88eb9e9d1e9d525f267b25f4ca6a58a8 100644
@@ -332,14 +332,16 @@ function Yargonaut () {
function findInModuleCache (lookingFor) {
var found = null
- for (var i = 0, files = Object.keys(require.cache); i < files.length; i++) {
- for (var j = 0; j < lookingFor.length; j++) {
- if (~files[i].lastIndexOf(lookingFor[j])) {
- found = files[i]
- break
+ if (require.cache) {
+ for (var i = 0, files = Object.keys(require.cache); i < files.length; i++) {
+ for (var j = 0; j < lookingFor.length; j++) {
+ if (~files[i].lastIndexOf(lookingFor[j])) {
+ found = files[i]
+ break
+ }
}
+ if (found) break
}
- if (found) break
}
return found
}