Node.JS 错误:找不到模块“posix” (使用 Cygwin)
我正在尝试使用 Cygwin 运行 一个简单的 Node.js Web 服务器。我将文件复制到test.js
在安装节点之后,这是我得到了什么。
$ node test.js
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'posix'
at Function._resolveFilename (module.js:299:11)
at Function._load (module.js:245:25)
at require (module.js:327:19)
at Object.<anonymous> (/home/me/test.js:27:13)
at Module._compile (module.js:383:26)
at Object..js (module.js:389:10)
at Module.load (module.js:315:31)
at Function._load (module.js:276:12)
at Array.<anonymous> (module.js:402:10)
at EventEmitter._tickCallback (node.js:108:26)
user@host ~
$
I am attempting to run a simple node.js webserver using Cygwin. I copied the file into test.js
after installing node and this is what I got.
$ node test.js
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'posix'
at Function._resolveFilename (module.js:299:11)
at Function._load (module.js:245:25)
at require (module.js:327:19)
at Object.<anonymous> (/home/me/test.js:27:13)
at Module._compile (module.js:383:26)
at Object..js (module.js:389:10)
at Module.load (module.js:315:31)
at Function._load (module.js:276:12)
at Array.<anonymous> (module.js:402:10)
at EventEmitter._tickCallback (node.js:108:26)
user@host ~
$
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您安装了哪个版本的节点?如果您查看节点更改日志,
require(' posix')
在版本 0.1.29 (2010.02.17) 中被移至 API 中的require('fs')
中。要点很老了。Which version of node did you install? If you take a look at the node change log,
require('posix')
was moved intorequire('fs')
in the API back in version 0.1.29 (2010.02.17). The gist is quite old.我将代码更新到最新的node.js版本:https://gist.github.com/862132 我仍然建议寻找其他更新的示例,因为这段代码不是很好(特别是在我更新它之后)。
I updated the code to the newest node.js build here: https://gist.github.com/862132 still I recommend finding other more recent example since this code is not that great (specially after I updated it).