I\'m getting the error while running the following code in Node.js
var assert = require(\'assert\');
var request = require(\'request\');
var index = require(\'./
With NodeJS modules, to make something public, you have to export it. Add this to the end of index.js
:
module.exports.AddNumbers = AddNumbers;
Here it is running on my machine:
$ cat index.js function AddNumbers(a,b){ return a+b; } module.exports.AddNumbers = AddNumbers; $ cat example.js var index = require('./index'); var v2 = index.AddNumbers(5,6); console.log(v2); $ node example.js 11