dimanche 15 mars 2015

Access function from require()'d file

Following is a code sample:


test.js:



function print(t){
console.log(t);
}


index.js:



var test = require('./test.js');
test.print("ok");


I get a test.show is not a function error, and I'm not sure why it won't work if with other npm modules seem to work. I am using browserify to make the require work in the browser.


How does requiring files that are not from a module work in npm?


Aucun commentaire:

Enregistrer un commentaire