Skip to content

Commit

Permalink
fix: check if module.paths really exists (#4194); closes #2505
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed May 5, 2020
1 parent 65daa9a commit 8b6a76c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/cli/cli.js
Expand Up @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion lib/mocha.js
Expand Up @@ -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'));
}
Expand Down

0 comments on commit 8b6a76c

Please sign in to comment.