【发布时间】:2012-03-21 10:43:20
【问题描述】:
我在我的 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/');
我不明白,那个文件确实存在!
【问题讨论】:
-
您是如何安装 Node.js 的,您在 Windows 下在什么 shell 中运行它? (cmd.exe、command.com、Cygwin、Git Bash、PowerShell、一些我不知道的 shell?)我从来没有遇到过你在 Windows、Mac 或 Linux 上提到的问题。
-
你确定文件存在吗...我不想问你是不是弄乱了文件扩展名之类的?尝试在我的 Windows 机器上运行这个 dl.dropbox.com/u/17781372/example.js - 5 分钟前安装的节点,它运行良好。
-
@DavidEllis 我刚刚使用了 Windows 安装程序,我正在使用 cmd.exe(我什至尝试右键单击并以管理员身份运行)
-
@MattEsch Esch 我知道鉴于错误,我一定看起来很疯狂,但文件确实存在。我也遇到了同样的错误。
-
@DavidEllis 我的路径:C:\Users\Smith>echo %PATH% C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x8 6)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\ Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files ( x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Common File s\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\12.0\ DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Users\Smith\AppData\ Roaming\npm;C:\Program Files (x86)\nodejs\
标签: node.js