更新时间:2023-08-23 23:12:58
/ code>主文件中的 server.js
文件(例如 app.js
): p>
var app = require(app)
,server = require(./ server)
;
并且在服务器.js
您可以拥有的文件:
require(http)。createServer(function(req ,res){
res.end(从电子应用程序启动的服务器发出的问候!);
})。listen(9000)
Im using GitHub Electron to create Desktop application with web technologies.
I'm using Node.js
as the server, my problem is that i don't know how to run the file server.js
just when launching the electron app.
I want to package my app for distribution so that i can run the server without the command line $ node server.js
.
Just simply require
the server.js
file in your main file (e.g. app.js
):
var app = require("app")
, server = require("./server")
;
...
And in the server.js
file you can have:
require("http").createServer(function (req, res) {
res.end("Hello from server started by Electron app!");
}).listen(9000)