substack/node-browserify — Issue #112: How to use jquery-browserify and other *-browserify libs
Author: superfeedr
Created: 2012-01-30 16:34:45+00:00
State: open

Hello,

I am completely lost on how to use jquery-browserify, and what is the actual goal for it.

In my node.js application I use (and require 'jquery'), because it just works fine.
Now, when compiling my application using browserify, I get the following error:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module "location" from directory "/Users/julien/repos/msgboy/node_modules/jquery"
at Function. (/usr/local/lib/node_modules/browserify/lib/wrap.js:363:19)
at Function.require (/usr/local/lib/node_modules/browserify/index.js:159:28)
at /usr/local/lib/node_modules/browserify/lib/wrap.js:441:14
at Array.forEach (native)
at Function. (/usr/local/lib/node_modules/browserify/lib/wrap.js:440:27)
at Function.require (/usr/local/lib/node_modules/browserify/index.js:159:28)
at /usr/local/lib/node_modules/browserify/lib/wrap.js:441:14
at Array.forEach (native)
at Function. (/usr/local/lib/node_modules/browserify/lib/wrap.js:440:27)
at Function.require (/usr/local/lib/node_modules/browserify/index.js:159:28)

So, I assumed this was because I needed to use the jquery-browserify.
I tried replacing all the require('jquery') with require('jquery-browserify'), but then I have issues because it seems that this module makes calls to `window` which obviously isn't defined in node.js.

So, I used `--alias 'jquery:jquery-browserify'` to compile my application. It does compile just fine, but then, I get an error in my browser: `Uncaught Error: Cannot find module 'jquery-browserify'`

So I'm a bit lost. What's the goal of jquery-browserify and how to use it?