0
我試圖將我的服務器與其變量放在對象中以保持我的項目清潔,所以我創建了core.js文件,該文件包含所有服務器變量,看起來像這樣:無法在對象中創建服務器node.js
module.exports =
{
express: require('express'),
http: require("http"),
app: this.express(),
server: this.http.createServer(this.app),
io: require('socket.io').listen(this.server),
runServer: function()
{
...........
}
};
我需要我的主要文件,在這個文件中:
var core = require("./server/classes/core");
當我嘗試運行我得到這個錯誤:
app: this.express(),
^
TypeError: this.express is not a function
可能是什麼問題?
一切工作都在兩種方式,但我更喜歡第一個。不知道一切都在同一時間定義在對象... – Donatas
@Donatas,偉大的伴侶,只要upvote它,如果你喜歡它:-) – Aruna