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

Native node modules are not loaded correctly #48

Closed
mihail-stanchev opened this issue May 20, 2015 · 1 comment
Closed

Native node modules are not loaded correctly #48

mihail-stanchev opened this issue May 20, 2015 · 1 comment

Comments

@mihail-stanchev
Copy link
Contributor

I have this situation: a sandboxed module loads sequelize, which in turn loads the sqlite3 module.
sqlite3 has a native module (.node) implementation. Somewhere in the chain of calls to require sandboxed-module tries to compile the content of the native module as source code, which leads to an error, obviously.

I have worked around this issue locally by adding a check if the extension of the file to be loaded is ".node":

if (builtinModules.indexOf(request) >= 0 || path.extname(request) == ".node") {
   if (request in cache) return cache[request];
   return require(request);
}

I am happy to submit a pull request if you find this okay.

@domenic
Copy link
Collaborator

domenic commented May 20, 2015

Pull request (with test!) welcome

mihail-stanchev pushed a commit to mihail-stanchev/node-sandboxed-module that referenced this issue May 21, 2015
@domenic domenic closed this as completed in a0385f7 Jun 2, 2015
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

No branches or pull requests

2 participants