npm install bcrypt安装失败

时间:2018-08-30 06:52:11

标签: javascript node.js express

我正在处理一个快速js,并希望安装bcrypt模块进行数据身份验证,但是一次又一次地收到此错误。

  

bcrypt@3.0.0安装/ media / iron / 1d6c195f-2350-423c-a3f0-0500c92e580a / admin-template / vuely2 / Vuely / node_modules / bcrypt   node-pre-gyp安装--fallback-to-build

node-pre-gyp WARN Pre-built binaries not installable for bcrypt@3.0.0 and node@9.11.0 (node-v59 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib' 
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/build'
gyp ERR! System Linux 4.4.0-134-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt
gyp ERR! node -v v9.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:936:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Linux 4.4.0-134-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt
node-pre-gyp ERR! node -v v9.11.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.2
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/admin-template/vuely2/Vuely/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@3.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/iron/.npm/_logs/2018-08-30T06_44_17_236Z-debug.log

节点:v9.11.0

Npm:6.4.1

node-pre-gyp:0.11.0

1 个答案:

答案 0 :(得分:0)

在此问题中,您只需安装 bcrypt-nodejs bcryptjs 即可,而不是 bcrypt ,如下所示:

npm install --save bcrypt-nodejs && npm uninstall --save bcrypt

之后,只需在文件 server.js 中调用此方法,如下所示:

var bcryptNodejs = require('bcrypt-nodejs'); //Or bcryptjs