Failure to require files on my local filesystem #2

ggoodman opened this Issue Nov 30, 2010 · 4 comments


None yet
2 participants

I have saved a copy of node-router.js to my local filesystem under that same name. Attempts to include that file in a second file, test.js have all failed. It seems that require() is silently returning null.


matthewfl commented Dec 1, 2010

I know there is a problem with searching for the module like how it is done in node, and thus exact file names must be used.
From testing just now it seems that if you do not have a ./ in the require statement it will not throw any errors and just return null, but if you have ./wrong_file_name it will throw an error that the file is not found.

For now require('./node-router.js') should work

Note: that for you local file system it will always require a ./ (or similar) in the require statement, the issue is that it is not failing when the name is wrong for the built in modules

ggoodman commented Dec 1, 2010

Hey Matthew, I've put together a little test case to illustrate my problem.

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write("./node-router.js:\t" + (typeof require('./node-router.js')) + "\n");
  res.write("./node-router:\t" + (typeof require('./node-router')) + "\n");
  res.write("node-router.js:\t" + (typeof require('node-router.js')) + "\n");
  res.write("node-router:\t" + (typeof require('node-router')) + "\n");

Results in the following:

./node-router.js:   undefined
./node-router:  undefined
node-router.js: undefined
node-router:    undefined

matthewfl commented Dec 1, 2010

I did see your spicific problem and I will be working on a fix, but when I save the result of require to a variable I get a different result where the first two work when node-router is saved as node-router and node-router.js.
This is just a workaround for now, and I will be trying to find the problem.


matthewfl commented Dec 4, 2010

This issue should be fixed now and live on the server.

This issue was closed.

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