module.extensions #4384

alvarolm opened this Issue Dec 6, 2012 · 4 comments

2 participants


module.extensions doesnt seems to be working properly, the example given on returns nothing.
node@0.8.12 | linux | ia32

node js file (run.js):

#!/usr/bin/env node
var sys=require("sys"), fs = require('fs');

    require.extensions['.jse'] = function(module, filename) {
      var content = fs.readFileSync(filename, 'utf8');
      module.exports = content;



jse file (0.jse):

#! /usr/bin/env node
console.log('IT WORKS!')

$ ls -al *.jse *.js

-rwxr-xr-x 1 alvaro alvaro 46 dic 6 17:26 0.jse
-rwxr-xr-x 1 alvaro alvaro 314 dic 6 17:32 run.js

file --mime *.js *.jse

run.js: text/plain; charset=us-ascii
0.jse:  text/plain; charset=us-ascii

$ node run.js

it outputs

#! /usr/bin/env node
console.log('IT WORKS!')

instead of:


whats wrong?

@bnoordhuis bnoordhuis closed this in c79fd0e Dec 6, 2012
Node.js Foundation member

Thanks, I've removed the broken example in c79fd0e. You can't implement that functionality without depending on private internals anyway.


how!?, can you give me a guide ? (:

Node.js Foundation member

You compile it with module._compile(contents, filename).


Thank you!

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