[英]Error installing bcrypt with npm
I'm unable to install bcrypt
using npm
on my machine because I encounter the following errors.我无法在我的机器上使用
npm
安装bcrypt
因为我遇到了以下错误。 I have been troubleshooting the issue without much luck.我一直在对问题进行故障排除,但运气不佳。 Can you recommend any steps to diagnose or fix the problem so I can run
npm install bcrypt
successfully?你能推荐任何诊断或修复问题的步骤,以便我可以成功运行
npm install bcrypt
吗?
Someones-Macbook:node_modules Cody$ npm install bcrypt
npm WARN package.json grunt-contrib-htmlmin@0.1.3 No README data
|
> bcrypt@0.7.7 install /Applications/MAMP/htdocs/richintime/ultimate-seed/node_modules/bcrypt
> node-gyp rebuild
child_process: customFds option is deprecated, use stdio instead.
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
../src/bcrypt_node.cc:118:18: error: no member named 'Dispose' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function>
>'
callback.Dispose();
~~~~~~~~ ^
../src/bcrypt_node.cc:202:19: error: unknown type name 'uv_work_t'
void GenSaltAsync(uv_work_t* req) {
^
../src/bcrypt_node.cc:219:24: error: unknown type name 'uv_work_t'
void GenSaltAsyncAfter(uv_work_t* req) {
^
../src/bcrypt_node.cc:220:17: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/bcrypt_node.cc:228:44: error: no member named 'New' in 'v8::String'
argv[0] = Exception::Error(String::New(baton->error.c_str()));
~~~~~~~~^
../src/bcrypt_node.cc:229:19: error: no matching function for call to 'Undefined'
argv[1] = Undefined();
^~~~~~~~~
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: candidate function not viable: requires single argument 'isolate', but no
arguments were provided
friend Handle<Primitive> Undefined(Isolate* isolate);
^
../src/bcrypt_node.cc:232:19: error: no matching function for call to 'Undefined'
argv[0] = Undefined();
^~~~~~~~~
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: candidate function not viable: requires single argument 'isolate', but no
arguments were provided
friend Handle<Primitive> Undefined(Isolate* isolate);
^
../src/bcrypt_node.cc:238:20: error: member reference type 'v8::Persistent<v8::Function>' is not a pointer; maybe you meant to use '.'?
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
~~~~~~~~~~~~~~~^~
.
../src/bcrypt_node.cc:238:22: error: no member named 'Call' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
~~~~~~~~~~~~~~~ ^
../src/bcrypt_node.cc:238:36: error: no member named 'GetCurrent' in 'v8::Context'
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
~~~~~~~~~^
../src/bcrypt_node.cc:246:34: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle<Value> GenerateSalt(const Arguments &args) {
^~~~~~~~~
v8::internal::Arguments
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:127:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/bcrypt_node.cc:247:17: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/bcrypt_node.cc:249:32: error: type 'const v8::internal::Arguments' does not provide a subscript operator
const ssize_t rounds = args[0]->Int32Value();
~~~~^~
../src/bcrypt_node.cc:250:30: error: type 'const v8::internal::Arguments' does not provide a subscript operator
const int rand_len = args[1]->Int32Value();
~~~~^~
../src/bcrypt_node.cc:251:58: error: type 'const v8::internal::Arguments' does not provide a subscript operator
Local<Function> callback = Local<Function>::Cast(args[2]);
~~~~^~
../src/bcrypt_node.cc:255:45: error: 'New' is a private member of 'v8::PersistentBase<v8::Function>'
baton->callback = Persistent<Function>::New(callback);
^
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:572:23: note: declared private here
V8_INLINE static T* New(Isolate* isolate, T* that);
^
../src/bcrypt_node.cc:255:57: error: too few arguments to function call, expected 2, have 1
baton->callback = Persistent<Function>::New(callback);
~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8.h:572:3: note: 'New' declared here
V8_INLINE static T* New(Isolate* isolate, T* that);
^
/Users/Cody/.node-gyp/0.12.0/deps/v8/include/v8config.h:289:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
^
../src/bcrypt_node.cc:259:5: error: unknown type name 'uv_work_t'
uv_work_t* req = new uv_work_t;
^
../src/bcrypt_node.cc:259:26: error: unknown type name 'uv_work_t'
uv_work_t* req = new uv_work_t;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt_node.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.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Applications/MAMP/htdocs/richintime/ultimate-seed/node_modules/bcrypt
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "bcrypt"
npm ERR! node v0.12.0
npm ERR! npm v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@0.7.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.7.7 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
The easy solution is just switch from the "bcrypt" npm module to bycryptjs
or bcrypt-nodejs
.简单的解决方案是从“bcrypt” npm 模块切换到
bycryptjs
或bcrypt-nodejs
。 It's the exact same API, but pure JS so no native add-ons to deal with.它是完全相同的 API,但是是纯 JS,因此无需处理本机附加组件。
npm install --save bcryptjs && npm uninstall --save bcrypt
Then change your require
calls to "bcryptjs", but all your code otherwise can be unchanged.然后将您的
require
调用更改为“bcryptjs”,但您的所有代码都可以保持不变。
Long term, I suspect at the moment bcrypt may not be ready for node v0.12.0 yet, but if not it will eventually be updated and ready.从长远来看,我怀疑目前 bcrypt 可能还没有为节点 v0.12.0 做好准备,但如果没有,它最终会被更新并准备好。
For windows install the following module:对于 Windows 安装以下模块:
npm install -g node-gyp
npm install --g --production windows-build-tools
Then try to install:然后尝试安装:
npm install bcrypt
On this command:在这个命令上:
npm install --g --production windows-build-tools
You may have to run this in Powershell as administrator on your Windows machine.您可能必须在 Windows 计算机上以管理员身份在 Powershell 中运行它。
You do that by right-clicking on Powershell and select "Run As Administrator"您可以通过右键单击 Powershell 并选择“以管理员身份运行”来执行此操作
The accepted solution works, but bcryptjs is slower than python and C++ version.接受的解决方案有效,但 bcryptjs 比 python 和 C++ 版本慢。
If you still want bcrypt instead of bcryptjs, working solutions are the commands below, but they can also have their own problems.如果你仍然想要 bcrypt 而不是 bcryptjs,工作解决方案是下面的命令,但它们也可能有自己的问题。
✔️ npm install -g node-gyp
❌ npm install --g --production windows-build-tools
In Windows, the second command will try to install Visual Studio along with python and hence the problem arises because the Visual Studio installation takes a lot of time.在 Windows 中,第二个命令将尝试与 python 一起安装 Visual Studio,因此出现问题是因为 Visual Studio 安装需要很多时间。 Also it also hinders the installation of python.
它还阻碍了python的安装。 If you forget to run those commands as Administrator, then they will get installed at C:\\Users\\User.windows-build-tools which will still not work because node will search for python in C:\\ or C:\\Program Files.
如果您忘记以管理员身份运行这些命令,那么它们将安装在 C:\\Users\\User.windows-build-tools 中,但仍然无法工作,因为 node 将在 C:\\ 或 C:\\Program Files 中搜索 python。 Hence these commands in some cases may increase your complications.
因此,在某些情况下,这些命令可能会增加您的复杂性。
So the best idea for you is to ✔️install python manually for All Users.所以对你来说最好的主意是✔️为所有用户手动安装python。 It is not necessary to add python to the environment path.
没有必要将 python 添加到环境路径中。
Then run:然后运行:
✔️ npm install -g node-gyp
Now you are ready to install bcrypt:现在您已准备好安装 bcrypt:
npm install bcrypt
Upgrade to bcrypt@5.0.0升级到bcrypt@5.0.0
npm i bcrypt@5.0.0
I am not getting errors on this newer version of bcrypt, older version gave different types of errors ranging from not able to install bcrypt to typescript type errors我在这个较新版本的 bcrypt 上没有收到错误,旧版本给出了不同类型的错误,从无法安装 bcrypt 到打字稿类型错误
在 Mac OS 上,在 Xcode 更新后,运行sudo gcc
并接受 Xcode 的新许可证解决了问题!
我只是运行以下然后尝试安装,它工作:
npm install node-pre-gyp -g
I was facing the same issue on the server side( aws ubuntu 16.04).我在服务器端(aws ubuntu 16.04)面临同样的问题。
I tried deleting node_module/bcrypt by sudo rm -rf node_module/bcrypt
multiple times and reinstalled it again and again by various ways but still facing the same issue.我尝试通过
sudo rm -rf node_module/bcrypt
多次删除 node_module/bcrypt 并通过各种方式一次又一次地重新安装它,但仍然面临同样的问题。
I checked node version with nvm and it was also showing stable (v10.11.0).我用 nvm 检查了节点版本,它也显示稳定(v10.11.0)。
Finally, I tried.最后,我试过了。
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
and it worked for me.它对我有用。
If you are on windows run powershell as administrator and use these commands.如果您在 Windows 上以管理员身份运行 powershell 并使用这些命令。
npm install --g --production windows-build-tools
and then install bcrypt using然后使用安装 bcrypt
npm install --save bcrypt
I was also having the same problem.我也遇到了同样的问题。 The following commands helped me.
以下命令帮助了我。
npm rebuild
then然后
npm install bcrypt
Reason for Error : Node maybe can't able to find the Python path on your system错误原因:节点可能无法在您的系统上找到 Python 路径
Solution解决方案
step: 1 Rum command prompt as administrator step 2 Install the package步骤:1以管理员身份运行命令提示符步骤 2安装软件包
npm install --global --production windows-build-tools
It may take some while, keep patient可能需要一段时间,请耐心等待
step 3 Now install第 3 步现在安装
npm install node-gyp
Last step Now you are ready to Go最后一步现在你准备好了
npm install bcrypt
I managed to solve this by running the command: sudo apt-get install -y build-essential python
and then yarn add bcrypt
.我设法通过运行以下命令解决了这个问题:
sudo apt-get install -y build-essential python
然后yarn add bcrypt
。
You can find the instructions here:您可以在此处找到说明:
https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions
https://github.com/kelektiv/node.bcrypt.js https://github.com/kelektiv/node.bcrypt.js
I installed bcrypt-nodejs though it's already deprecated, and then removed it and installed bcrypt again.我安装了 bcrypt-nodejs,尽管它已经被弃用,然后将其删除并再次安装 bcrypt。 Like this, I Installed bcrypt successfully and it worked fine.
像这样,我成功安装了 bcrypt 并且运行良好。
yarn add bcrypt-nodejs
yarn remove bcrypt-nodejs
yarn add bcrypt
if any of the above fails to work, do:如果上述任何一项不起作用,请执行以下操作:
npm install node-gyp
Afterwards visit the official python download site Official Python download link之后访问官方python下载站点官方Python下载链接
Install the latest version of python, make sure to check add python to path安装最新版本的python,一定要勾选add python to path
After installation, do:安装后,执行:
npm --save install bcrypt
Running跑步
sudo apt install build-essential
installs all the tools you need to install bcrypt on Linux.安装在 Linux 上安装 bcrypt 所需的所有工具。 Then you can run
然后你可以运行
npm install
我有节点版本 12.18.3 并通过运行npm i bcrypt@3.0.6
修复了相同的npm i bcrypt@3.0.6
This happened to me as I was installing a package from github that had an older version of bcrypt as a dependency.这发生在我身上,因为我正在从 github 安装一个包,该包有一个旧版本的 bcrypt 作为依赖项。 I just uninstalled the old bcrypt version and installed the newest version:
我刚刚卸载了旧的 bcrypt 版本并安装了最新版本:
npm uninstall bcrypt
npm install bcrypt
Then, voila.然后,瞧。 It worked.
有效。
Had the same problem.有同样的问题。 Updating npm and try again (npm install -g npm usually).
更新 npm 并重试(通常是 npm install -g npm)。 It fix the issue for me.
它为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.