Node.js在我打开它时关闭 [英] Node.js closes as I open it
问题描述
var http = require(http );
fs = require('fs');
fs.readFile('./ index.html',function(err,html){
if(err){
throw err;
}
});
http.createServer(function(request,response){
response.writeHead(200,{Content-Type:text / plain});
response。写(Hello World);
response.end();
})。listen(1994);
无论何时启动应用程序,它立即关闭。我在控制台上看到应用程序启动半秒的文本,但窗口关闭。这种情况每次都会发生。
卸载并重新安装nodejs,然后更新问题就解决了。我认为,这只是针对几个未解决的问题的Windows新手而已。问题是几个月前,所以我忘记了确切的细节。在Windows中使用命令提示符shell会导致问题(正如人们可以想象的那样)。
I am running a very simple script in nodejs, loading a static html file.
var http = require("http");
fs = require('fs');
fs.readFile('./index.html', function (err, html) {
if (err) {
throw err;
}
});
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(1994);
Whenever I launch the application it immediately closes. I see the text on the console for the half second that the application launches, but then the window closes. This happens every time.
After uninstalling and re-installing nodejs, and then updating the problem was solved. I think that it was simply node being new to windows with a few unaccounted for issues. The problem was a few months ago, so I forget the exact specifics. Using command prompt shells in windows leads to problems (as one can imagine.)
这篇关于Node.js在我打开它时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!