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

Prevent Node from adding paths outside the app to search paths #2976

Merged
merged 3 commits into from Oct 3, 2015

Conversation

zcbenz
Copy link
Member

@zcbenz zcbenz commented Oct 3, 2015

The module system of Node tends to iterate every parent folder of the required module and add everyone of them to search paths, it makes sense for Node, but in Electron this mechanism may happen to override app's modules with unrelated ones when user's system has lots of Node modules installed.

A classic problem is users have third party dialog module installed somewhere, resulting in require('dialog') calls in app not working.

This PR solves this problem by limiting the propagated paths to be inside the process.resourcesPath, so packaged app can avoid accidentally using modules installed in user's machine. And for require calls that explicitly use modules outside the app, there will be no limitation, otherwise unexpected behaviors may happen.

Fixes #2626.

zcbenz added a commit that referenced this pull request Oct 3, 2015
Prevent Node from adding paths outside the app to search paths
@zcbenz zcbenz merged commit 9a2e2b3 into master Oct 3, 2015
@zcbenz zcbenz deleted the node_modules_paths branch October 3, 2015 13:20
@fritx
Copy link
Contributor

fritx commented Oct 3, 2015

awesome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants