Heroku + Facebook + NodeJS:找不到模块'OAuth'

时间:2012-02-17 08:06:55

标签: facebook node.js heroku oauth-2.0

我是NodeJS的新手,所以这可能很容易解决。但是我无法用目前的理解水平找到解决方案。

我从Github克隆了heroku-facebook-nodejs模板,并尝试在我的本地服务器上的开发环境中进行一些测试。我使用的是nodejs版本0.6.10

https://github.com/heroku/facebook-template-nodejs

我修改了package.json,如下所示:

{
  "name":        "facebook-template-node",
  "version":     "0.0.1",
  "description": "Template app for Heroku / Facebook integration, Node.js language",
  "dependencies": {
    "ejs": "0.4.3",
    "everyauth": "0.2.18",
    "express": "2.5.2",
    "facebook-client": "1.3.0",
    "facebook": "0.0.3",
    "node-uuid": "1.2.0",
    "socket.io": "0.8.7",
    "connect": "1.8.5"
  }
}

我删除了以下内容:

require.paths.unshift(__dirname + '/lib');

并替换

var socket_manager = require('socket_manager').create(io);

var socket_manager = require('lib/socket_manager').create(io);

然后运行npm-install -d在本地安装模块。

当我运行节点web.js时,我收到以下错误:

system-process:hollow-cloud-1974 ericjang2004$ node web.js 
The "sys" module is now called "util". It should have a similar interface.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'oauth'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/Eric/Desktop/hollow-cloud-1974/node_modules/everyauth/lib/modules/oauth2.js:2:13)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)

我不知道该怎么办。有小费吗?我读到Heroku使用较旧版本的Node,如果有帮助的话。

2 个答案:

答案 0 :(得分:3)

将“oauth”:“0.9.5”添加到package.json中的依赖项中,如下所示:

"dependencies": {
    "ejs": "0.4.3",
    "oauth": "0.9.5",
    "everyauth": "0.2.18",
    "express": "2.5.2",
    "facebook-client": "1.3.0",
    "facebook": "0.0.3",
    "node-uuid": "1.2.0",
    "socket.io": "0.8.7",
    "connect": "1.8.5"
  }

并运行npm install -d

答案 1 :(得分:1)

运行npm install whatever --save代替将确保将模块添加到包json。

如果它是开发依赖项,你会npm install whatever --save-dev ...