From e548131ef52083cdd156713dea287bf2021747d0 Mon Sep 17 00:00:00 2001 From: emanuele Date: Fri, 28 Feb 2020 09:16:59 +0000 Subject: [PATCH] fix: check if module.paths really exists --- lib/cli/cli.js | 4 +++- lib/mocha.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cli/cli.js b/lib/cli/cli.js index dee8e70dd4..af0e7841d6 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -30,7 +30,9 @@ const {repository, homepage, version, gitter} = require('../../package.json'); exports.main = (argv = process.argv.slice(2)) => { debug('entered main with raw args', argv); // ensure we can require() from current working directory - module.paths.push(process.cwd(), path.resolve('node_modules')); + if (typeof module.paths !== 'undefined') { + module.paths.push(process.cwd(), path.resolve('node_modules')); + } Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit? diff --git a/lib/mocha.js b/lib/mocha.js index 740e1fd841..21b1ad40bf 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -29,7 +29,7 @@ exports = module.exports = Mocha; * To require local UIs and reporters when running in node. */ -if (!process.browser) { +if (!process.browser && typeof module.paths !== 'undefined') { var cwd = process.cwd(); module.paths.push(cwd, path.join(cwd, 'node_modules')); }