Running node.js code just displays a node identifier

前端 未结 9 2121
爱一瞬间的悲伤
爱一瞬间的悲伤 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:50

    Was getting this when I was trying to run cordova commands. Steps to resolve:

    Windows

    1. In CMD prompt, type "where node". As Michael mentioned, this shows you the likely culprit, that you have 2 nodejs EXEs installed on your machine.
    2. Navigate to Start > Computer > Right-click Properties > Advanced system settings
    3. Under the Advanced tab, select Environment Variables
    4. Under System variables, select "Path" variable
    5. Find nodejs EXE, usually "C:\Program Files (x86)\nodejs\"
    6. Cut and paste this to the beginning of the "Path" variable. Ensure the paths are separated by a ";"
    7. Open a new CMD prompt and try cordova again

提交回复
热议问题