Home > front end >  CMD run js script files submitted to the Windows script host mistake how to solve
CMD run js script files submitted to the Windows script host mistake how to solve

Time:09-16

The code below
var http=require('http');

HTTP. CreateServer (function (request, response) {

//sending HTTP headers
//HTTP status value: 200: OK
//content type: text/plain
Response. WriteHead (200, {' the content-type: 'text/plain "});

//send the response data "Hello World"
The response. The end (' Hello World \ n ');
}), listen (8888);

//terminal to print the following information
The console. The log (' Server running at http://127.0.0.1:8888/);
Error:

CodePudding user response:

Not with the WSH to execute the js, want to use the node. Js command-line execution environment, both js host environment is different,
The command line window:
D: \ nodejs \ node. Exe D: \ \ XXXX XXXX. Js

CodePudding user response:

CodePudding user response:

The last is how to solve?

CodePudding user response:

Performs nodejs environment in CMD code, need to add node before the execution of file
  • Related