作爲一個初學者到這的NodeJS可能straigtforward,但尚未我無法揣摩出我錯了功能要求()拋出未定義的錯誤
我home.js文件是遵循
module.exports = function (deps) {
var sample = require('../lib/sample'), // My own library
express = require('express'),
router = express.Router();
router.get('/', function (req, res) {
op = sample.parse('hi'); // Error here
res.send(op);
});
return router;
};
在lib文件夾,我的sample.js代碼
module.exports = function() {
function parse(text) {
return 'hello' + text;
}
return {
'sample': {
'parse': parse
}
};
};
但我得到一個錯誤說上突出顯示的行undefined is not a function
。任何人都可以讓我知道我失蹤了嗎?