安装Node.js中的bycrpt出现错误?每当我运行npm install install --save时?

3
> bcrypt@3.0.0 install C:\projects\alecadApi\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

`node-pre-gyp` WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.0/bcrypt_lib-v3.0.0-node-v57-win32-x64-unknown.tar.gz
`node-pre-gyp` WARN Pre-built binaries not found for bcrypt@3.0.0 and node@8.10.0 (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
`C:\projects\alecadApi\node_modules\bcrypt\build\bcrypt_lib.vcxproj(20,3)`: error MSB4019: The imported project "C:\Microsoft.Cp
p.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk
.
`gyp ERR!` build error
`gyp ERR!` stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
`gyp ERR!` System Windows_NT 10.0.17134
`gyp ERR!` command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\adity\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\projects\\alecadApi\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\projects\\alecadApi\\node_modules\\bcrypt\\lib\\binding" "--napi_version=1" "--node_abi_napi=napi"
`gyp ERR!` cwd C:\projects\alecadApi\node_modules\bcrypt
`gyp ERR`! node -v v8.10.0
`gyp ERR!` node-gyp -v v3.6.2
`gyp ERR!` not ok
`node-pre-gyp` ERR! build error
`node-pre-gyp` ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\projects\alecadApi\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\alecadApi\node_modules\bcrypt\lib\binding --napi_version=1 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Projects\alecadApi\node_modules\bcrypt\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
`node-pre-gyp` ERR! stack     at emitTwo (events.js:126:13)
`node-pre-gyp` ERR! stack     at ChildProcess.emit (events.js:214:7)
`node-pre-gyp` ERR! stack     at maybeClose (internal/child_process.js:925:16)
`node-pre-gyp` ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
`node-pre-gyp` ERR! System Windows_NT 10.0.17134
`node-pre-gyp` ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Projects\\alecadApi\\node_modules\\bcrypt\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
`node-pre-gyp` ERR! cwd C:\projects\alecadApi\node_modules\bcrypt
`node-pre-gyp` ERR! node -v v8.10.0
`node-pre-gyp` ERR! node-pre-gyp -v v0.10.2
`node-pre-gyp` ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\projects\alecadApi\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\alecadApi\node_modules\bcrypt\lib\binding --napi_version=1 --node_abi_napi=napi' (1)
`npm WARN` alecadApi@1.0.0 No repository field.
`npm WARN` optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
`npm WARN` notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

`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!`     C:\Users\adity\AppData\Roaming\npm-cache\_logs\2018-07-07T10_51_34_631Z-debug.log```

只需在终端中键入 npm install bcrypt --save - Ankit Halder
6个回答

5

您应该使用

npm install --save bcrypt

进行适当的安装。

顺便提一下,如果您想使用bcrypt,需要安装Python。如果您想独立于Python使用,请使用bcryptjs。

npm install --save bcryptjs

5
你尝试过这个吗?这个

Open powershell with administrator privileges and run this command, then proceed with bcrypt installation.

npm install --global --production windows-build-tools
注意:等待在 PowerShell 窗口上看到“All Done!”后,再继续安装模块。

这完美地解决了我的问题。windows-build-tools支持Node.js的所有纯C++插件,包括:node-sass、bcrypt、sqlite3、serialport、websocket、deasync、grpc、canvas、sharp、hiredis、leveldown、nodegit、zqm、ffi、libxmljs、iconv、ref、sleep、microtime、couchbase、bignum、kerberos和ursa。 - Jaskaran Singh
很高兴听到这个。 :) - mrSerious

2

尝试使用这个版本,它对我有用... npm i bcrypt@3.0.6


2

您需要单独安装bcrypt。

执行npm install bcrypt --save,等待安装完成后再次运行npm install

您还可以查看此链接,获取类似问题的答案。

如果上述方法无效,您可以使用bcrypt-nodejsbcryptjs包。


2

对于一些可能遇到这个问题的人

情况

如果您之前能够正确安装。然后在升级nodejs(对我来说,我从11升级到12)之后,您就无法安装了。

如果您遇到以下错误:

Original Answer: "If you get"
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

能够解决问题的方法(对我有效)

完全删除bcrypt。(从package.json中删除,然后执行npm install --save)。

然后重新安装。

如果你遇到像这样的错误。当你运行npm rebuild时,会出现其他错误。

最初的回答

npm install bcrypt --save 

它成功安装并且构建没有问题。
(您可以忽略删除部分)。

试了一个多小时才弄明白,你的简单解决方案起作用了。谢谢! - user2402616

0
我遇到了这个问题,是因为我的node js版本是12.8.3。我只是将我的node版本更改为12.4.1。然后尝试使用npm i bcrypt安装bcrypt。现在它对我来说运行良好。
链接检查/下载不同的Node.js版本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接