substack/node-browserify — pull request #929 by AjayMT (2014-10-02 15:27:50+00:00)
Title: Document internal require resolving. Closes #913.

browserify resolves requires within an application, unlike node. Since most people don't know this, they run into errors when they try to do stuff like this:

```javascript

// abc/foo.js

var bar = require('./lib/bar.js');

```

```javascript

// abc/lib/bar.js

// this would work with node because abc/lib/baz.js exists
// but browserify resolves the path and complains that abc/baz.js doesn't exist
var baz = require('./baz.js');

module.exports = baz;

```

Everyone is therefore forced to do this:

```javascript
var baz = require(path.join(__dirname, 'baz.js'));
```

Obviously, that's a better (and safer) practice, but people are too used to node's relative-to-__dirname requires. That's why I decided to just document this instead of changing browserify.

(Also, documenting it takes less effort :))

This should fix issue #913.