简体   繁体   English

Node.JS错误:找不到模块“ posix”(使用Cygwin)

[英]Node.JS Error: Cannot find module 'posix' (using Cygwin)

I am attempting to run a simple node.js webserver using Cygwin. 我正在尝试使用Cygwin运行一个简单的node.js Web服务器 I copied the file into test.js after installing node and this is what I got. 我在安装节点后将文件复制到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 ~
$

Which version of node did you install? 您安装了哪个版本的节点? If you take a look at the node change log , require('posix') was moved into require('fs') in the API back in version 0.1.29 (2010.02.17). 如果您查看节点更改日志 ,则会将API中的require('posix')移回到版本0.1.29(2010.02.17)中的require('fs')中。 The gist is quite old. 要点很老。

我将代码更新为最新的node.js构建: https : //gist.github.com/862132仍然建议您查找其他较新的示例,因为此代码不是那么好(特别是在我对其进行更新之后)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM