Brunch require with node.js modules

I have Brunch set up for ease of compiling JS together, but want to also be able to use a node.js module with require. After trying for a while, I'm stumped. I want to be able to do something like this:

var myJSfile1 = require('foo');
var myJSfile2 = require('bar');
var nodeJSdependency = require('node-fubar');

where app/ contains foo.js and bar.js, and in package.js I have a dependency for node-fubar. What happens, of course, is that when I run brunch watch --server it say it's compiled fine, but whe I open it in the browser, I get the console error of

Error: Cannot find module "node-fubar" from "app"

If I try the following:

var nodeJSdependency = require('../node_modules/node-fubar');

the error changes to:

Error: Cannot find module "node_modules/node-fubar" from "app"

Am I doing something wrong, or is what I'm trying to do not possible? If it's not, how would you suggest going about it? Having the browser and the node dependency are both essential but Brunch may not be (I'm just fond of it).

Thanks in advance!



Nodejs modules are not supported in brunch.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.