Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Using .alias for relative requires #184

jed opened this Issue · 5 comments

3 participants


I'm trying to create localized browserify bundles, and my code looks something like this:


// build the english version
var b = browserify()


var locale = require("locale")


module.exports = {
  hello: "Hello!"

but I keep getting errors like Error: Cannot find module: "locale" from directory [blah]... Are relative directories not supported for .alias, or am I doing it wrong?


Aliases are a bit screwy in how they map paths to other paths. Try doing b.alias('/node_modules/locale/index.js', '/locales/en')

jed commented

I'll try that. Thanks, @substack.

jed commented


i've boiled this down to the smallest test case possible, but still can't get it to work. one of the following always happens:

  1. compilation fails and i get Error: Cannot find module: "locale" from directory "/Users/jed/Desktop/3038799" while processing file /Users/jed/Desktop/3038799/src.js
  2. compilation succeeds and i get the run-time error Error: Cannot find module 'locale'

would love if you could take a look at this. here's a quick one liner to test it.

git clone git:// && cd 3038799 && npm i && npm test

I would love a fix for this too. Currently I have to include the full path, which is annoying for things like js/lib/lib-1.8.21.min.js.

As far as I can tell, .alias() only works for npm modules. Using it for local dependencies never works because there is no entry for an aliased module in require.modules.


There are no aliases in v2 but you can do a similar kind of thing with .expose() across multiple bundles.

@substack substack closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.