gpt4 book ai didi

node.js - NPM :Cannot find module 'bcrypt'

转载 作者:太空宇宙 更新时间:2023-11-04 03:07:08 24 4
gpt4 key购买 nike

我收到错误 Cannot find module 'bcrypt' in nodejs application,我尝试使用 npm install bcrypt 安装它,但仍然遇到问题。

Error: Cannot find module 'bcrypt'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\achraf\Desktop\crud\cruds\api\models\Todo.js:9:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at C:\Users\achraf\AppData\Roaming\npm\node_modules\sails\node_modules\include-all\index.js:129:29
at Array.forEach (native)
at requireAll (C:\Users\achraf\AppData\Roaming\npm\node_modules\sails\node_modules\include-all\index.js:44:9)
at buildDictionary (C:\Users\achraf\AppData\Roaming\npm\node_modules\sails\node_modules\sails-build-dictionary\index.js:68:14)
at Function.module.exports.optional (C:\Users\achraf\AppData\Roaming\npm\node_modules\sails\node_modules\sails-build-dictionary\index.js:160:9) { [Error: Cannot find module 'bcrypt'] code: 'MODULE_NOT_FOUND' }

最佳答案

bcrypt 需要本地构建。如果您不习惯使用 c++ 编译器构建它,我建议您看一下 bcrypt-nodejs 模块。它基本上更容易做同样的事情:

var bcrypt = require('bcrypt-nodejs');

示例:

bcrypt.genSalt(10, function(err, salt) {
if (err) return err;

bcrypt.hash(attrs.password, salt, null, function(err, hash) {
attrs.password = hash;
});
});

关于node.js - NPM :Cannot find module 'bcrypt' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36773499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com