8000 dynamic requires don't find files in the browser · Issue #377 · browserify/browserify · GitHub
[go: up one dir, main page]

Skip to content
dynamic requires don't find files in the browser #377
@btakita

Description

@btakita

I'm trying to require a file dynamically.

<section data-view="views/root" id="root"></section>

I have a parse method which parses the DOM for data-view and requires that file.

function parse() {
  _.each($('[data-view]'), function(el) {
    var $el = $(el);
    require('./' + $el.data('view'));
  })
}

I then get the following error in the browser "Error: Cannot find module './views/root'". It works when I execute the code in node.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0