我已完成npm install connect
但Error: Cannot find module 'connect/middleware/session/memory'
并未在输出中消失。哪个套餐没有安装?
windows 7
C:\Users\guo\Desktop\js8_chat\chat>node -v
v0.10.26
C:\Users\guo\Desktop\js8_chat\chat>npm -v
1.4.3
express@3.5.1
var express = require('express'),
sio = require('socket.io'),
fs=require('fs'),
path = require('path')
url = require('url'),
parseCookie = require('connect').utils.parseCookie,
MemoryStore = require('connect/middleware/session/memory');
错误:
module.js:340
throw err;
^
Error: Cannot find module 'connect/middleware/session/memory'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\guo\Desktop\js8_chat\chat\chat.js:11:16)
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)
感谢。
答案 0 :(得分:3)
如果您尝试创建MemoryStore
和cookieParser
,则可以像这样创建:
var EXPRESS_SID_KEY = 'express.sid';
var COOKIE_SECRET = 'very secret string';
var cookieParser = express.cookieParser(COOKIE_SECRET);
var sessionStore = new express.session.MemoryStore();
app.configure(function () {
app.use(cookieParser);
app.use(express.session({
store: sessionStore,
cookie: {
httpOnly: true
},
key: EXPRESS_SID_KEY
}));
});
你想要达到的目标存在于快递模块中,你必须将其视为
var MemoryStore = require('express\node_modules\connect\lib\middleware\session\memory')