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

Module "vm" missing. #6

Open
kegesch opened this issue Mar 16, 2018 · 7 comments
Open

Module "vm" missing. #6

kegesch opened this issue Mar 16, 2018 · 7 comments

Comments

@kegesch
Copy link

kegesch commented Mar 16, 2018

Nice work with this repo!
My app apparently requires "vm", but the "vm-browserify" alias was removed (in c0fb559).
Can you explain why? Is there a specific reason?

@parshap
Copy link
Owner

parshap commented Mar 20, 2018

vm-browserify uses window.document and dom elements in its implementation, so it won't work in RN. I don't know of a RN-compatible polyfill for vm, but it may be possible to create one. It'd be great if you can contribute one! Or even a "mock" one that stubs out empty functions if that's all you need to get your library working.

@kegesch
Copy link
Author

kegesch commented Mar 20, 2018

Okay, thank you for the explanation. A mock would propably enough for my usage, but i got it working with adding vm-browserify (i think it is not using the the function at all but just checks if the library is there?) with configuring the rn-cli.config.js like:

'use strict';
const nodelibs = require('node-libs-react-native');
nodelibs.vm  = require.resolve('vm-browserify');

module.exports = {
    extraNodeModules: nodelibs,
};

@ka-sh
Copy link

ka-sh commented Jul 11, 2018

Am having the same issue. @parshap what would be an acceptable solution? a mock or actually using vm-browserify ? if so will create a pull request to cover the VM case

@parshap
Copy link
Owner

parshap commented Jul 12, 2018

I think a mock is the best solution unless you actually need sandboxing for security. Adding a vm mock to mock/ would be awesome.

@toddpi314
Copy link

toddpi314 commented Nov 29, 2018

note above, you might want to use the resolver syntax:

'use strict';
const nodelibs = require('node-libs-react-native');
nodelibs.vm  = require.resolve('vm-browserify');

module.exports = {
  resolver: {
    extraNodeModules: nodelibs
  },
};

I'm not sure how @Y0nnyy's original snippet would work without that..

@PrognosticatorR
Copy link

Can't find variablebtoaafter adding metro.config.js

@pcowgill
Copy link
Contributor

note above, you might want to use the resolver syntax:

Yep, and in addition to using resolver syntax, these days the file would be named metro.config.js rather than rn-cli.config.js

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

6 participants