获得Microsoft JScript编译错误 [英] Getting Microsoft JScript compilation error

查看:1117
本文介绍了获得Microsoft JScript编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用运行一段代码first.js

var http = require("http");

http.createServer(function (request, response) {

   // Send the HTTP header
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});

   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(8124);

// Console will print the message
console.log('Server running at http://127.0.0.1:8124/');

当我用gitbash运行它给它的欲望输出。但是使用node js命令提示它给出了microsoft jscript编译错误。

while i m running it with gitbash its giving desire output. but with node js command prompt its giving microsoft jscript compilation error.

推荐答案

这里的问题可能来自几个地方。最有可能是基于安装的。

The issue here could stem from several places. Most likely installation-based.

以下代码(取自上面)

var http = require("http");
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n'); }).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');

当我尝试在浏览器中加载时,会产生正面结果。
因此,我推荐以下内容:

Yields positive results when I attempt to load it in the browser. I therefore recommend the following:


  1. 尝试将我放入代码段窗口的内容运行到全新的first.js文件中在一个全新的目录中,从命令行导航到该目录并使用命令Node first.js运行该文件(自然没有引号)。

1.1如果使用除纯文本编辑器(记事本++,记事本,升华等)之外的任何编辑器,请确保该文件实际上设置为输出纯文本(骨头移动但经常被忽略)

1.1 If using any editor aside from a plain text editor (notepad++, notepad, sublime etc) ensure the file is in-fact set to output plain-text (bone-head move but often overlooked)


  1. 重新安装节点(值得一试)

  1. Reinstall node (Worth a shot)

如果所有其他方法都失败并且你安装了npm,输入npm install http并重新运行你的first.js应用程序

If all else fails and you have npm installed, type "npm install http" and re-run your first.js application

这篇关于获得Microsoft JScript编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆