Webstorm/node.js dev using server side modules in browser

Hi All

I've only been doing this for a week but have hit a problem.  I have a centralised server side module (sparkfuncs.js) that gets variables from a remote site.  This all works fine and dandy.  However, at the top of the file is a require statement (var spark = require ('spark.js')).  You can probably guess the rest.

I'd like to access the functions in sparkfuncs from a web page. However, as the word require is not standard javascript, I get an error message in the JavaScript Console in Chrome which is:

Uncaught ReferenceError: require is not defined

I've done plenty of reading and think I need requirejs.js to get around the problem.  I've read the docs and examples about a million times and can't seem to understand it.  I'm assuming it gets around this problem so I'm keen to get it fixed.

Has anyone else had the same problem and how did they fix it?

Thanks for reading.....

Steve

1 comment
Comment actions Permalink

Please see http://stackoverflow.com/questions/19059580/client-on-node-uncaught-referenceerror-require-is-not-defined.
If you like to use CommonJS-like syntax in your client-side code, I'd suggest using Browserify

0

Please sign in to leave a comment.