question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browserify a Browserified module

See original GitHub issue

So I have three modules to use in an app in a browser.

module-b depends on module-a.

module-a depends on Handlebars and is composed of several individual internal dependencies, relatively required as in the documentation. module-a’s foo.js requires bar.js, like so:

var Handlebars = require('handlebars');
var bar = require('./bar.js');

I browserify module-a. I run it through tests, and everything is good and index.js is produced and it contains foo, bar, and Handlebars and the exports look good and are tested via the requires in the test, so, I npm link module-a.

I go to module-b and npm link module-a, which installs a symlink in the node_modules folder of module-b.

When I browserify module-b, which has a statement of var module-a = require('module-a');, I get a bunch of browserify errors, like the following:

Error: module "./handlebars/base" not found from "/home/blah/Development/module-b/node_modules/module-a/index.js"

This seems strange, since module-a is already browserified. I’ve tried with -r module-a, -x module-a, --ignore-missing, -i 'handlebars'. Browserify just keeps spitting out the same error. I assume that it would fail for module-a's internal ./bar.js dependency as well, but it dies before it even gets that far.

Is this expected behavior, is it a bug, or am I not configuring the cli call to browserify correctly?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ForbesLindesaycommented, Nov 5, 2013

Another option is to minify the result. That way all the require functions would get renamed, so they would be ignored by browserify.

1reaction
adamjgrantcommented, Sep 2, 2014

@zpao @jperkelens So what exactly needs to be done to solve this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browserify
Browserify lets you require('modules') in the browser by bundling up all of your dependencies. Install Documentation · Source Code · Help + Articles...
Read more >
browserify/browserify: browser-side require() the node.js way
Use a node-style require() to organize your browser code and load modules installed by npm. browserify will recursively analyze all the require() calls...
Read more >
Getting Started with Browserify - SitePoint
Browserify allows us to use node.js style modules in the browser. We define dependencies and then Browserify bundles it all up into a...
Read more >
Lesson 3. Bundling modules with Browserify
Broswerify is a tool that lets you define modules, the same way Node.js does during development, and then bundle them into a single...
Read more >
Browserify - npm
browser-side require() the node way. Latest version: 17.0.0, last published: 2 years ago. Start using browserify in your project by running ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found