如何停止Node.js服务器?

问题描述 投票:0回答:2

我刚刚在我的DigitalOcean服务器上设置了MEAN堆栈。我得到了测试应用程序运行正常,但现在当我从DigitalOcean打开命令行时,它只显示信息:GET / modules / etc ...而我输入的部分是空白的。如何停止服务器并将其恢复到原来的位置,以便我可以访问文件夹等?

简单地执行CTRL + C并不会阻止服务器运行,这是我需要做的。

node.js mean-stack digital-ocean
2个回答
0
投票

你在用什么?你在命令提示符或终端中尝试控制+ c了吗?

编辑:转到您正在使用的config.js文件或服务器文件,以指定要使用的端口。如果您在browswer localhost:port中测试localhost类型

var http = require('http'); 
var url = require('url'); 
http.createServer(function (req, res) { 
 console.log("Request: " + req.method + " to " + req.url); 
 res.writeHead(200, "OK"); 
 res.write("<h1>Hello</h1>Node.js is working"); 
 res.end(); 
}).listen(8080); 
console.log("Ready on port 8080");

0
投票

您可以通过终止进程来停止服务器。在Windows中,运行CMD并键入taskkill /F /IM node.exe这将终止(停止)所有Node.js进程。然后你可以重新启动它。

© www.soinside.com 2019 - 2024. All rights reserved.