我最近切换到Ubuntu 14.04,也在我的Mac机上工作。此项目是从同一个仓库克隆的,但在两台机器上的行为不同。我不知道为什么,请帮帮我。
我用这行来散列我的密码,它在我的mac机器上工作正常。
var hashed = crypto.pbkdf2Sync(entered,this.salt,12000,128).toString('hex');
但是,在Ubuntu中,它会出现以下错误:
> node ./bin/www
crypto.js:574
var ret = binding.PBKDF2(password, salt, iterations, keylen, digest);
^
TypeError: Not a buffer
at TypeError (native)
at pbkdf2 (crypto.js:574:23)
at Object.exports.pbkdf2Sync (crypto.js:553:10)
at model.<anonymous> (/media/linux/app/dataModel/userModel.js:30:33)
at _next (/media/linux/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:62:30)
at fnWrapper (/media/linux/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:186:18)
at model.Object.defineProperty.value.fn (/media/linux/app/node_modules/mongoose/lib/schema.js:215:9)
at _next (/media/linux/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:62:30)
at fnWrapper (/media/linux/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:186:18)
at /media/linux/app/node_modules/mongoose/lib/schema.js:198:13
at complete (/media/linux/app/node_modules/mongoose/lib/document.js:1107:5)
at /media/linux/app/node_modules/mongoose/lib/document.js:1133:20
at ObjectId.SchemaType.doValidate (/media/linux/app/node_modules/mongoose/lib/schematype.js:645:22)
at /media/linux/app/node_modules/mongoose/lib/document.js:1129:9
at doNTCallback0 (node.js:407:9)
at process._tickCallback (node.js:336:13)
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! code ELIFECYCLE
npm ERR! app@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the bocerapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /media/linux/app/npm-debug.log
提前致谢!