CNode

栽倒在入门的超级新手啊,windows7,各位大神请指教

Mminmintemuer发布于14 年前最后回复14 年前15 回复8470 浏览0 收藏

我写的 hello.js var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.jsn');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

运行 node hello.js 结果显示: ReferenceError:hello is not defined at repl:1:2 at ... ...

node.js:201 throw e; //process.nextTick error.or 'error' event on first tick ReferenceError:hello is not defined at Object. .... ..... .....

查看回复

回复 (15)

J
jiyinyiyong#1·14 年前

代码看去没问题.. 应该多给点信息的, 楼主怎么操作的, 步骤怎样?
非常怀疑是在 REPL 里面输入 hello.js 了..
顺带看下之前这个帖有没有帮助: http://club.cnodejs.org/topic/4f62e75e8a06477f5211a892

B
be5invis#2·14 年前

估计是输 node 之后 hello 了吧 应该是命令行里直接输入:

X:\work_dir> node hello

M
minmintemuer#3·14 年前
引用 be5invis估计是输 node 之后 hello 了吧 应该是命令行里直接输入: X:\work dir node hello

按你说的执行,结果是:node.js:201 throw e; //process.nextTick error.or 'error' event on first tick ReferenceError:hello is not defined at Object. <D:Node\hello.js:1:16> .... ..... .....

X
xian366#4·14 年前

@minmintemuer 输入 node hello.js试试

M
minmintemuer#5·14 年前
引用 xian366@minmintemuer 输入 node hello.js试试

node.js:116 throw e; // process.nextTick error, or 'error' event on first tick ^ ReferenceError: hello is not defined at Object. (/home/Wang/node-v0.4.0/hello.js:1:63) at Module._compile (module.js:373:26) at Object..js (module.js:379:10) at Module.load (module.js:305:31) at Function._load (module.js:271:10) at Array. (module.js:392:10) at EventEmitter._tickCallback (node.js:108:26) 这是我用cygwin安装的,路径/home/Wang/node-v0.4.0/hello.js。。。。

X
xian366#6·14 年前
引用 xian366@minmintemuer 输入 node hello.js试试

@minmintemuer 版本怎么还是0.4的?

M
minmintemuer#7·14 年前
引用 xian366@minmintemuer 输入 node hello.js试试

@xian366 因为在 Windows 上0.6的用cygwin不支持,还有,我直接装.msi的也不行,也是这个错误,明明当时的路径有文件,它非说 is not defined

X
xian366#8·14 年前
引用 xian366@minmintemuer 输入 node hello.js试试

@minmintemuer 我觉得node 还是在linux 或 mac os x 上吧。

J
jeffz#9·14 年前

楼主要学会用markdown贴代码,看文章和回复里那个乱的……

M
minmintemuer#11·14 年前

问题已解决,谢谢大家的热心,原因。。。。。。是js文件我是用sublime text 写的,因为第一次用所以第一行的文件名也存进去了,导致js文件无法运行

S
simongfxu#13·14 年前

致楼主

  • 作为一个码农,必须要学会 markdown 啊。

  • widnows下面很折腾,还是装个 linux

  • 论坛很多热心人,你来对地方了。

  • nodejs 很有前景,不要放弃。

    var testFunc = function(){ return this; };

J
jiyinyiyong#15·14 年前
引用 minmintemuer问题已解决,谢谢大家的热心,原因。。。。。。是js文件我是用sublime text 写的,因为第一次用所以第一行的文件名也存进去了,导致js文件无法运行

@jeffz 楼上回复的时间比我早大半天..
不过想想自己当时作个新手, 在知乎被人扯到 Markdown, 真无奈的
还有编辑器支持也纠结

参与回复
登录后即可参与回复。登录