Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node errors when not using r.js #2

Open
kn0ll opened this issue Jun 8, 2012 · 6 comments
Open

node errors when not using r.js #2

kn0ll opened this issue Jun 8, 2012 · 6 comments

Comments

@kn0ll
Copy link

kn0ll commented Jun 8, 2012

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
@jrburke
Copy link
Member

jrburke commented Jun 9, 2012

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

@kn0ll
Copy link
Author

kn0ll commented Jun 9, 2012

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.

@jrburke
Copy link
Member

jrburke commented Jun 9, 2012

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.

@DragonDTG
Copy link

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');

requirejs.config({ 
  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) {
  console.log(template);
}

@JudahGabriel
Copy link

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.

@jrburke
Copy link
Member

jrburke commented Oct 18, 2012

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants