&引用;“未定义”不是一个函数;使用mongoose会话和express时出错

&引用;“未定义”不是一个函数;使用mongoose会话和express时出错,express,mongoose,runtime-error,Express,Mongoose,Runtime Error,当我初始化应用程序时,一切都正常,但当我转到任何页面时 像“localhost/”一样,我得到以下错误(双重:一次用于index.html,一次用于请求的javascript,请参见下文): 这是我正在使用的代码: var express = require('express'); var app = this.__app = express(); app.use(express.bodyParser()); app.use(express.cookieParser()); app.use(ex

当我初始化应用程序时,一切都正常,但当我转到任何页面时 像“localhost/”一样,我得到以下错误(双重:一次用于index.html,一次用于请求的javascript,请参见下文):

这是我正在使用的代码:

var express = require('express');
var app = this.__app = express();
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({
     store: this.__getSessionStore()
    ,secret: this.__secretSession
}));

app.post('/rpc', this.__manageRequest.bind(this)); // <-- this method is not even called
app.use("/client", express.static('./client/')); // 
// gets the index.html, but files in subfolders (which exists) throws the second error in the double error 
app.use("/", express.static('./client/production/build')); 

app.listen(this.__appPort, this.__appIp);
快速版本:3.0.0 Mongoose会话版本:0.2.0

未定义的方法在hash方法中是“crc16”:在debug中也是未定义的

function hash(sess) {
  return crc16(JSON.stringify(sess, function(key, val){
    if ('cookie' != key) return val;
  }));
}
在crc模块中,有一个if(窗口)和定义的窗口,问题是我看不到它定义在哪里! 由于此窗口,它不会导出任何模块,因此该函数未定义!我只是非常老练地删除了if(窗口)以始终导出到它的模块。 嗯,这是一个错误的crc@0.2.0模块(https://github.com/alexgorbatchev/node-crc/pull/10),而《快车》要求的正是这个版本

问题到底是什么?如何解决?
非常感谢

这只是第一次起作用,然后失败,再次出现同样的错误…

由于会话mongoose中的依赖项如下(松散地):

它下载了猫鼬3.5.4!Npm应该只下载了3.0,但我不知道发生了什么

现在我删除了它,把猫鼬放在了和我的应用程序3.4.0相同的版本上

我仍然不知道3.5.4版本出了什么问题,或者问题是否不一样,但这里是修复方法


因为这个损失了这么多时间…:S

也许可以编辑./node_modules/express/package.json,告诉它使用更新的CRC库

更改行:

"crc": "0.2.0",

然后跑

npm install -d
如果未安装更新的crc库,请手动删除文件夹./node_modules/express/node_modules/crc,然后重试


我不保证这会奏效,但值得一试

嗯,当crc作者更新crc模块时,没有更改版本,所以仍然是crc@0.2.0,但有两个不同的版本在一个。。。所以必须删除文件夹并重新安装crc。。。或者可能是crc@0.2.0在git中与在npm中不同。。还不知道,因为我是直接从git复制的。
"dependencies": {
  "mongoose": ">= 3.0"
},
"crc": "0.2.0",
"crc": ">= 0.2.0",
npm install -d