node errors when not using r.js #2

kn0ll opened this Issue Jun 8, 2012 · 6 comments

4 participants


i was able to get the text plugin working with requirejs as a node module, but it took a bit of modification. is the text plugin intended to work via node, without using r.js? if so, what could i be doing wrong? if not, what can we do to get real npm support?

below are errors and my resolutions...

Error: Calling node's require("text") failed with error: Error: Cannot find module 'text'
# create text in node_modules

Error: Calling node's require("text") failed with error: ReferenceError: define is not defined
# add amdefine compatibility

Error: Calling node's require("text") failed with error: TypeError: Object #<Module> has no method 'config'
# change module.config() to {}

Error: Object function has no method 'nodeRequire'
# change require.nodeRequire to require
requirejs member

Why not just use fs.readFileSync() when in node/not running via r.js?


i'm sharing the same modules between the client and the server; and i'd prefer not to have to split logic between the two. thanks btw requirejs is literally my favorite lib ever.

requirejs member

OK so you are just running the modules in node without using r.js, but just relying on amdefine? In that case it makes sense to get these changes in. If you already have the changes done and want to do a pull request that would be great.


Hi, I'm using the jam.js version (2.0.0-jam.1) of the text plugin and I managed to get it working on the client and the server without modification using require.js for both sides. I just registered text as a package in node.js.

var requirejs = require('requirejs');

  packages: [{
      name: 'text',
      location: '../path_to_scripts/jam/text',
      main: 'text.js'

And use it in the follow statement.

requirejs(['text!path_to_template'], function(template) {

I hit the same problem as catshirt. I made the same changes to text.js as he did, and that fixed the problem.

Unfortunately, DragonDTG's solution didn't work. I also tried the stubModules functionality, couldn't get it to properly ignore the text module.

requirejs member

I guess I am a bit lost on the use case. @JudahGabriel Maybe you can lay out the directories involved, how the text plugin is loaded/referenced. A small test case in a github repo would be ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment