Skip to content

Module "vm" missing. #6

Open
Open

Description

@kegesch

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?

Activity

  1. parshap commented on Mar 20, 2018

    @parshap
    Owner

    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.

  2. kegesch commented on Mar 20, 2018

    @kegesch
    Author

    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,
    };
    
  3. ka-sh commented on Jul 11, 2018

    @ka-sh

    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

  4. parshap commented on Jul 12, 2018

    @parshap
    Owner

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

  5. toddpi314 commented on Nov 29, 2018

    @toddpi314

    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..

  6. devesrawat commented on Dec 24, 2019

    @devesrawat

    Can't find variablebtoaafter adding metro.config.js

  7. pcowgill commented on Dec 30, 2019

    @pcowgill
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions