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

Require fails at runtime with "Cannot find module ..' #6

Open
ammojamo opened this issue Jul 6, 2015 · 3 comments
Open

Require fails at runtime with "Cannot find module ..' #6

ammojamo opened this issue Jul 6, 2015 · 3 comments

Comments

@ammojamo
Copy link

ammojamo commented Jul 6, 2015

I have a basic sample project here:
https://github.com/ammojamo/gobble-browserify-require-broken

The project builds fine, but gobble-browserify generates a bundle where some (but not all) of the paths have been changed to start with '@' (seems to be some magic in cacheDependency). When you attempt to run the javascript in a browser (e.g. open the built index.html), it fails with the error:

Uncaught Error: Cannot find module '@/dependency.js'

Maybe related: the output also contains absolute paths (/Users/myname/etc...) and this is impossible to override in the options because gobble-browserify has options.fullPaths=true hard coded.

P.S. I have tried many build tools in many different languages and Gobble is easily my favourite. Well done! I just love the simplicity of it and confidence with which I can write custom transformations if I need to.

@bathos
Copy link

bathos commented Sep 2, 2015

Experiencing the same issue -- imported module is originally in a child /node_modules directory relative to the importer, and there's no error during build, but in the output bundle, the module appears to be mis-addressed with the @ stand-in.

@bathos
Copy link

bathos commented Sep 2, 2015

Follow up: this is fixed for me by switching from 0.6.1 to 0.6.0, so it seems this commit is connected to it.

@kthompson
Copy link

I have this issue as well. I was able to work around the issue by using the following 'configure' function:

    configure: function(bundle) {
      //Hack to correct the @ symbols and replace with the correct basedir
      var basedir = '';
      bundle.on( 'dep', function ( dep ) {
          if(dep.basedir)
            basedir = dep.basedir;

          for(var child in dep.deps) {
            if(dep.deps[child][0] == '@')    
            {
              dep.deps[child] = basedir + dep.deps[child].substring(1);           
            }
          }
      });
    },

This may have some side effects like preventing the caching mechanism from actually working...

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 a pull request may close this issue.

3 participants