node.js根本不运行

我在我的Mac上安装并运行了node.js,但是即使我在Windows上也这样做了

chdir c:\testfolder node example.js 

那么我得到这个错误:

 node.js:201 throw e; // process.nextTick error, or 'error' event on first tick Error: Cannot find module 'c:\testfolder\example.js' at Function._resolveFilename <module.js:322:11> at Function._load <module.js:299:25> at Array.0 <module.js:499:10> at EventEmitter._tickCallback <node.js:192:40> 

我只是甚至试图在nodejs网站上运行示例代码:

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

我不明白,那个文件是否存在!

很可能你的文件没有命名为example.js,但是如果你使用记事本创build了example.js.txt文件,并且它没有在你的机器上打开,以显示已知文件types的文件扩展名:)

当你键入: chdir c:\testfolder然后dir时,你将能够看到你的真实文件名