Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We shouldn't rely on the existence of "module.paths" (Meteor) #2505

Closed
apendua opened this issue Sep 27, 2016 · 4 comments · Fixed by #4194
Closed

We shouldn't rely on the existence of "module.paths" (Meteor) #2505

apendua opened this issue Sep 27, 2016 · 4 comments · Fixed by #4194
Labels
status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc.

Comments

@apendua
Copy link

apendua commented Sep 27, 2016

According to CommonJS specs, the paths property is optional. Depending on its existence, e.g.

https://github.com/mochajs/mocha/blob/master/lib/mocha.js#L28

may cause unnecessary runtime errors, for example:

benjamn/install#9

We should probably test against the property existence before modifying module.paths.

@boneskull
Copy link
Member

In this case, I think we can try / catch some require() statements when loading local UIs and reporters.

@boneskull boneskull added status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc. labels Sep 27, 2016
@boneskull boneskull changed the title We shouldn't rely on the existence of "module.paths" We shouldn't rely on the existence of "module.paths" (Meteor) Sep 27, 2016
@ematipico
Copy link
Contributor

ematipico commented Feb 27, 2020

Hi, is there any movement around this?
At the moment this is causing an issue. I am running mocha in a bundled file (I packed mocha using rollup) to be executed in a serverless environment.

I get an error in the following snippet:

if (!process.browser) {
  var cwd = process.cwd();
  module.paths.push(cwd, path$2.join(cwd, 'node_modules')); // <= here
}

module.paths doesn't exists.

@boneskull
Copy link
Member

Does the serverless environment not support module.paths?

As this is marked help wanted, if a contributor can find an alternative, we’d accept a PR to address.

@ematipico
Copy link
Contributor

ematipico commented Feb 27, 2020

I take a guess: could it be empty because there's no node_modules folder? As I bundled everything, I don't use the folder.

Would bypassing that lines of code break the framework? I could help if pointed to the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Mocha can use your help with this one! type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants