我正在制作节点程序。我想从孩子访问 app.js 参数。我在 parent 中使用了 module.exports,在 child 中使用了 module.parent.exports。但它没有用。我该如何解决?
(/app.js)
var app = module.exports = express();
(/routes/index.js)
var app = module.exports = module.parent.exports;
var port = app.get('port');
(错误信息)
/Users/satoshi/Google Drive/node/testoy2/routes/index.js:7
var port = app.get('port');
^
TypeError: Object #<Object> has no method 'get'
at Object.<anonymous> (/Users/satoshi/Google Drive/node/testoy2/routes/index.js:7:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/satoshi/Google Drive/node/testoy2/app.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
(版本)
node = v0.10.5
express = 3.2.4