我试图加入bcrypt-ruby,v.3.0.1.我在我的gem文件中输入gem,如下所示:
gem 'bcrypt-ruby', '3.0.1'
Run Code Online (Sandbox Code Playgroud)
然后我去终端并运行:
bundle install
Run Code Online (Sandbox Code Playgroud)
我收到以下回复:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
creating Makefile
make
compiling bcrypt_ext.c
make: gcc-4.2: No such file or directory
make: *** [bcrypt_ext.o] Error 1
Gem files will remain installed in /Users/philip7899/.bundler/tmp/2186/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/philip7899/.bundler/tmp/2186/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
我对Ruby和Rails都是新手,并且不知道如何解决这个问题.我已经看到其他stackoverflow页面有类似的问题,但没有一个能够帮助我.我最近升级到Mountain Lion,并被告知可能是一个问题.有人告诉我使用RVM卸载然后重新安装Ruby.我试过了,但没用.
请帮忙.谢谢.
之前已在此讨论过,但似乎没有结论.
理想情况下,不想在数据库等中维护状态(升级/未升级),所以,这就是我的想法:
bcrypt MD5密码,并使用"username + something else"作为盐.
我的节点Dockfile:
# Set the base image to ubuntu
FROM ubuntu
# Define working directory
ADD . /src
WORKDIR /src
# Install Node.js & other dependencies
RUN apt-get update && \
apt-get -y install curl && \
apt-get -y install sudo && \
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - && \
apt-get -y install python build-essential nodejs
RUN npm install -g node-gyp && \
node-gyp clean && \
npm cache clean
RUN node -v
# Install nodemon
RUN …Run Code Online (Sandbox Code Playgroud) 我尝试在heroku中进行部署时遇到问题.有趣的是,这是三天前的工作.此外,在本地机器上工作正常.
Bcrypt的版本是3.0.0,节点8.12.0
我真的需要部署这个服务器.你能告诉我如何解决这个错误吗?我尝试过一些我发现的解决方案但没有任何效果.我甚至尝试卸载并重新安装Bcrypt但不起作用.
谢谢您的帮助.
这是日志.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 8.x...
Downloading and installing node 8.12.0...
Using default npm version: 6.4.1
-----> Restoring cache
- node_modules
-----> Building dependencies
Installing node modules (package.json + package-lock)
> bcrypt@3.0.0 install /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
make: Entering directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
make: Entering directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
rm: cannot remove './Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw': …Run Code Online (Sandbox Code Playgroud) 我在rails 3上使用devise(当前gem)中的数据库身份验证,并且在尝试使用用户名/密码登录时出现以下错误.
no such file to load -- bcrypt_ext
This error occurred while loading the following files:
bcrypt
bcrypt_ext
Run Code Online (Sandbox Code Playgroud)
我之前已经"成功安装了bcrypt-ruby-2.1.2"宝石.
有任何想法吗?我也试过给Bundler git repo地址并获取master,但它没有解决问题.
系统规格:Mac OS X 10.9节点v0.10.22
尝试安装bcrypt时出现以下错误.有关如何解决此问题的任何建议?
任何帮助将不胜感激.
> bcrypt@0.7.6 install /Users/eDawg/Desktop/eggstage/node_modules/bcrypt
> node-gyp rebuild
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
../src/blowfish.cc:47:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
^
1 error generated.
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/eDawg/Desktop/eggstage/node_modules/bcrypt …Run Code Online (Sandbox Code Playgroud) 我遇到了BCrypt密码的问题:我的User模型都设置为has_secure_password和validates_presence_of :password.
重点是BCrypt使用password,password_confirmation但在模式中只有password_digest字段.
夹具抱怨该password字段不存在.
我怎么能避免这个?
谢谢
我已经将node.js v6.9.1和npm版本4.1.2一起安装了,我已经将这个组合用于了一些项目
现在我想bcrypt在我的项目中使用npm包,但安装失败了
npm install bcrypt --save
Run Code Online (Sandbox Code Playgroud)
我也尝试使用admin priviledges运行此命令,但无济于事
这是我得到的错误
> bcrypt@1.0.2 install C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcry
pt
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcryp
t.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@6.9.1 (
node-v48 ABI) (falling back to source compile with node-gyp)
C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node
"" clean )
C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback
-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\l
ib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\tthei
ner\NodeProjects\authtest\node_modules\bcrypt\lib\binding ) …Run Code Online (Sandbox Code Playgroud) 继这个问题之后.
我觉得我几乎就在那里,但我对异步的不完全理解阻止了我解决这个问题.我基本上试图使用bcrypt来散列密码并决定分离hashPassword函数,以便我可以在应用程序的其他部分使用它.
hashedPassword 保持返回undefined虽然...
userSchema.pre('save', async function (next) {
let user = this
const password = user.password;
const hashedPassword = await hashPassword(user);
user.password = hashedPassword
next()
})
async function hashPassword (user) {
const password = user.password
const saltRounds = 10;
const hashedPassword = await bcrypt.hash(password, saltRounds, function(err, hash) {
if (err) {
return err;
}
return hash
});
return hashedPassword
}
Run Code Online (Sandbox Code Playgroud) 我对 VueJS 中 bcrypt 的使用有点困惑......
我正在开发一个示例应用程序,其中 VueJS 作为 FE,NodeJS 作为 BE(+ Postgres 作为 DB)。
在 NodeJs 中,对我来说加密密码没有问题,但由于我是安全偏执狂,我不想将其以纯文本形式从 FE 发送到 BE。
问题是,我在 VueJS 中找不到任何有关 BCRYPT 的文档...
我能够安装它:
npm install --save bcrypt
> bcrypt@5.0.0 install /home/fe/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
[bcrypt] Success: "/home/fe/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL …Run Code Online (Sandbox Code Playgroud)