ReferenceError "not defined"
ReferenceError "not defined"
不用说,我是一个初学者(当你看到我的问题时,你可能会明白的)。
我安装了节点代码是创建一个http服务器(如下)
> `var http = require('http'),
host = '127.0.0.1',
port = '9000' ;
var server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type' :'text/html'}) ;
res.end ('<h1> Hello World Joseph </h1>') ;
}) .listen(port, host, function() {
console.log ('server Running on http://")' + host + ':' + port)
}) <
`
现在,我在一个名为hello.js的文件中有了这段代码我转到节点命令提示符,然后键入hello.js
我得到以下
ReferenceError: hello is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)
如有任何帮助,我们将不胜感激。
谢谢Joseph
我要回答的只是跟进我的评论:
我不确定你是否将<
和>
或``放在代码中进行堆栈溢出格式化,也就是说这里是正确的代码,本质上这些东西需要删除:
var http = require('http'),
host = '127.0.0.1',
port = '9000' ;
var server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type' :'text/html'}) ;
res.end ('<h1> Hello World Joseph </h1>') ;
}) .listen(port, host, function() {
console.log ('server Running on http://")' + host + ':' + port);
});
现在要在节点中运行该代码,只需转到包含该文件的目录,然后键入node hello.js
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- reactRedux is not defined
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- ReferenceError: not defined
- "“;变量未引用正确的对象
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- JavaScript/jQuery - "$ is not defined- $function()"