Running node.js code just displays a node identifier

前端 未结 9 2153
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 19:07

I have the following code in a file called server.js.

var http = require(\'http\');

http.createServer(function (request, response) {
  response.writeHead(200,          


        
9条回答
  •  忘掉有多难
    2021-02-19 19:56

    I think you're running the wrong node command. Try locating or re-downloading your nodejs installation and add it to your path as the first directory. If you're running linux or unix you can try 'which node' to see what is being run. Note that in some cases, the node.js executable is called nodejs so you may want to try nodejs server.js as well

提交回复
热议问题