substack/node-fileify — Issue #5: var files = require(fileifyName) inside browserify entry.js = troubles
Author: NHQ
Created: 2012-02-28 00:49:53+00:00
State: open

Greetings,

I use browserify to load my app, following prescribed bundling/entry techniques. On the server, at startup, I have browserify use fileify(fileifyName, '/dir') for some templates.

Inside the app, then, I have var files = require(fileifyName), but during the compilation process on the server, browserify errors: "Cannot find module "fileifyName" from directory "/Users/elenagragasin/...".

I have tested fileify same as above w/o the require() in the app, and verify it works as advertised, using the webkit debugger... the files are delivered to the browser. But when I stick require(fileifyName) in the app itself, it all breaks down before it gets started. It seems that browserify is trying to find module (fielifyName) before the module has been created, yet it works if I just leave out the require.

This gist is a redacted copy of the server, it doesn't look much different than your examples. https://gist.github.com/1928161

I'm using Node.js v.0.6.6

Many thanks