NodeJS alternative to PHP includes?
This question already has an answer here:
If you want to load only exported objects from external file, you can use require
function.
var imported = require('your-module');
If you want to execute external Javascript file directly into your global scope (similar to PHP's include
), then you should use eval
.
eval(require('fs').readFileSync('your-moduleindex.js') + '');
链接地址: http://www.djcxy.com/p/97014.html
上一篇: 导出模块Node.js
下一篇: NodeJS替代PHP包括?