Mac npm install bcrypt 时的一个错误

r/node_modules/bcrypt
node-pre-gyp ERR! node -v v12.16.2
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
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 build --fallback-to-build --module=/Users/y.han/My/code/opensource/3d/server/DataServer/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/Users/y.han/My/code/opensource/3d/server/DataServer/node_modules/bcrypt/lib/binding --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN dataserver@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@3.0.4 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!     /Users/y.han/.npm/_logs/2020-04-17T11_40_11_344Z-debug.log

找了很对方法 都不对

最后发现是版本 要和官网推荐的搭配。
https://www.npmjs.com/package/bcrypt

image.png

先查看自己nodejs 的版本 然后安装表中对应版本的bcrypt

推荐阅读更多精彩内容