Bcrypt 3.0.1 无法在节点 v 8.12.0 上安装

Bcrypt 3.0.1 fails to install on node v 8.12.0

Bcrypt 3.0.1 无法在节点 v 8.12.0 上安装

npm 调试日志:

1224 verbose stack Error: bcrypt@3.0.0 install: `node-pre-gyp install --fallback-to-build`
1224 verbose stack Exit status 1
1224 verbose stack     at EventEmitter.<anonymous> (d:\brd\app\node-v8.12.0-win-x64\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
1224 verbose stack     at emitTwo (events.js:126:13)
1224 verbose stack     at EventEmitter.emit (events.js:214:7)
1224 verbose stack     at ChildProcess.<anonymous> (d:\brd\app\node-v8.12.0-win-x64\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
1224 verbose stack     at emitTwo (events.js:126:13)
1224 verbose stack     at ChildProcess.emit (events.js:214:7)
1224 verbose stack     at maybeClose (internal/child_process.js:915:16)
1224 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
1225 verbose pkgid bcrypt@3.0.0
1226 verbose cwd d:\brd\proj18\projects\projectname
1227 verbose Windows_NT 6.1.7601
1228 verbose argv "d:\brd\app\node-v8.12.0-win-x64\node.exe" "d:\brd\app\node-v8.12.0-win-x64\node_modules\npm\bin\npm-cli.js" "i" "bcrypt@3.0.0" "--save"
1229 verbose node v8.12.0
1230 verbose npm  v6.4.1
1231 error code ELIFECYCLE
1232 error errno 1
1233 error bcrypt@3.0.0 install: `node-pre-gyp install --fallback-to-build`
1233 error Exit status 1
1234 error Failed at the bcrypt@3.0.0 install script.
1234 error This is probably not a problem with npm. There is likely additional logging output above.

如所述here it seems that this issue has been fix by this PR (#649),但修复程序尚未在 npm 存储库中发布。

知道如何解决这个问题吗?

解决方法是安装build-tools,这样angular就可以自己构建bcrypt了。

在 windows,这完成了工作:

npm --add-python-to-path='true' --debug install --global windows-build-tools

替代方法是使用 bcryptjs。

npm install bcryptjs --save