无法节点app.js因为'无法读取属性' MemoryStore'未定义的'

时间:2016-08-16 20:38:08

标签: node.js ubuntu vagrant

我使用vagrant和virtualbox with precise32进行设置。使用以下命令安装Node.js v0.10:

  1. curl -sL https://deb.nodesource.com/setup_0.10 | sudo bash -
  2. sudo apt-get install -y nodejs
  3. 并且我似乎无法对以下节点进行sudo节点:

    var everyauth = require('everyauth');
    var nconf = require('nconf');
    var Recaptcha = require('recaptcha').Recaptcha;
    var crypto = require('crypto');
    var connect = require('connect');
    var cookie = require('cookie');
    var express = require('express');
    
    var models = require('./models/');
    var hash = require('./hash');
    var config = require('./config');
    
    /* load API keys */
    nconf.env().file({file: 'settings.json'});
    
    var session_store = new connect.session.MemoryStore();
    

    我收到以下错误:

       TypeError: Cannot read property 'MemoryStore' of undefined
        at Object.<anonymous> (/vagrant/app/auth.js:16:40)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Module.require (module.js:364:17)
        at require (module.js:380:17)
        at Object.<anonymous> (/vagrant/app/app.js:8:12)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Function.Module.runMain (module.js:497:10)
        at startup (node.js:119:16)
        at node.js:945:3
     at node.js:945:3
    

    我不得不说,3年前我做这个项目的时候,我只是简单地做了“安装和安装”。并试图运行和everythin很好。我认为js和新安装的npm之间存在不兼容问题。

1 个答案:

答案 0 :(得分:0)

更改

var connect = require('connect');
...
var session_store = new connect.session.MemoryStore();

let app = express();
let session = require('express-session');
app.use(session({ ... });

或安装Express

的旧版本(2.x,3.x)