nodejs无法找到模块,可以在一台服务器上运行,但不能在另一台服

时间:2014-04-04 02:41:08

标签: node.js npm

我有一些代码正在两个不同的服务器上工作,在尝试将它移动到第三个之后,它就是轰炸,对于我的生活,我无法理解为什么。特定模块是node-memcached(由3rd-Eden),但由于它在多个其他位置工作,我不确定它是否相关。 3台服务器之间的唯一区别是我试图在这个新服务器上更新到节点0.10,而其他两台服务器都是0.6。

这是我看到的错误:

module.js:337
    throw new Error("Cannot find module '" + request + "'");
      ^
Error: Cannot find module 'Memcached'
    at Function._resolveFilename (module.js:337:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:359:17)
    at require (module.js:375:17)
    at Object.<anonymous> (/net/somepath/myproj/CCDataAccess.js:3:17)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:32)
    at Function._load (module.js:311:12)
    at Module.require (module.js:359:17)

我在项目中安装了memcached,如下所示:

cd /net/somepath/myproj/

npm install memcached

在同一个目录上使用npm list,我可以看到它列在那里

/net/somepath/myproj
├─┬ memcached@0.2.8
│ ├─┬ hashring@0.0.8
│ │ ├── bisection@0.0.3
│ │ └── simple-lru-cache@0.0.1
│ └─┬ jackpot@0.0.6
│   └── retry@0.6.0

memcached的实际require语句嵌套在启动js深层的3个文件中,但实际的调用是这样的:

var Memcached = require('Memcached');

此时我不确定接下来要尝试做什么。任何建议,指导甚至可能是解决方案都将非常感谢!

1 个答案:

答案 0 :(得分:0)

来自memcached npm页面

var Memcached = require('memcached');
var memcached = new Memcached(Server locations, options);

尝试不使用大写字母M

你有没有做过

npm install 

在项目目录中?