From 69b21f013ab2128142323ad42933c9881fc01489 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Fri, 20 Nov 2015 09:58:28 +0800 Subject: [PATCH] Fix eslint module not found error --- lib/linter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/linter.js b/lib/linter.js index 649b4e6..ec87f42 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -29,7 +29,13 @@ module.exports = function (cwd, args, text) { process.chdir(cwd); var cwdEslint = eslintMap[cwd]; if (!cwdEslint) { - var cwdPath = resolve.sync('eslint', { basedir: cwd }); + var cwdPath; + // resolve will throw an error, if module not found + try { + cwdPath = resolve.sync('eslint', { basedir: cwd }); + } catch (e) { + // module not found + } cwdEslint = cwdPath ? require(cwdPath) : require('eslint'); eslintMap[cwd] = cwdEslint; }