Skip to content Skip to sidebar Skip to footer

Error: Require.paths Is Removed. When Running Node.js & Socket.io

(javascript) Iv got an error in running a socket.io example from github https://github.com/LearnBoost/socket.io.git when i run -> node app.js it says. Error: require.paths is r

Solution 1:

I hit this issue while working with a cloud foundry sample. The offending line they told you to include was:

require.paths.unshift('./node_modules')

It's apparently a way of telling node what path to search in for modules you require, in those cases where you don't provide an explicit path. I read somewhere that's when the string you pass in does not start with a dot or a slash.

As far as I can tell it's something that is required to make Node 0.4 applications search in the node_modules directory. But in Node 0.6 you're supposed to sort this out with settings in your environment and path instead (though it seemed to work by default for me on an 0.6 install).

I was having trouble because the cloud deployment was on Node 0.4 and my local development setup was on Node 0.6. Having the line crashed me locally, but leaving it out crashed on the cloud. My solution was to delete it and instruct the cloud to use 0.6 with:

vmc push <appname> --runtime=node06

Everything seemed to work after that. Even better: I found that you can edit your manifest.yml file to tell it do this automatically during the push with no command line switch needed:

---applications:.:name:myappruntime:node06# added this lineframework:name:nodeinfo:mem:64Mdescription:Node.jsApplicationexec:n

(etc.)

Incidentally...if it had been necessary to dual support older versions of node that needed require.paths as well, one could maybe run the line conditionally based on testing process.version:

http://nodejs.org/docs/v0.4.9/api/process.html#process.version

Solution 2:

May be you can try https://github.com/cloudhead/less.js/issues/320 This is something similar to your problem.

Solution 3:

try something like this:

var dust = require('dustjs-helpers');

var compiled = dust.compile("Hello {name}!", "intro");

dust.loadSource(compiled);

dust.render("intro", {
    name: "Márcio"
}, function(err, out) {
    console.log(out);
});

Post a Comment for "Error: Require.paths Is Removed. When Running Node.js & Socket.io"