解决参考网址:
https://github.com/nodejs/node-gyp#installation
解决过程:
1
通过查找资料等,需要先安装gyp,gyp在windows版本下需要很多配置环境
根据参考网址https://github.com/nodejs/node-gyp#installation
C:\WINDOWS\system32>npm install --global --production windows-build-tools
/
> windows-build-tools@0.6.0 postinstall F:\Program Files\nodejs\node_global\node_modules\windows-build-tools
> node ./lib/index.js
Downloading BuildTools_Full.exe
Downloading python-2.7.11.msi
[> ] 0.0% (0 B/s)
Downloaded python-2.7.11.msi. Saved to C:\Users\dell\.windows-build-tools\python-2.7.11.msi.
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!
Waiting for installers... |Successfully installed Visual Studio Build Tools.
Successfully installed Python 2.7
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\node_modules\rimraf requires glob@'^7.0.5' but will load
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\node_modules\glob,
npm WARN unmet dependency which is version 4.5.3
windows-build-tools@0.6.0 F:\Program Files\nodejs\node_global\node_modules\windows-build-tools
├── cli-spinner@0.2.5
├── debug@2.2.0 (ms@0.7.1)
├── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.1)
├── fs-extra@0.30.0 (path-is-absolute@1.0.1, klaw@1.3.0, jsonfile@2.4.0, graceful-fs@4.1.9, rimraf@2.5.4)
└── nugget@2.0.1 (throttleit@0.0.2, minimist@1.2.0, single-line-log@1.1.2, progress-stream@1.2.0, request@2.75.0, pretty-bytes@1.0.4
2
F:\Program Files\nodejs\node_global\marked -> F:\Program Files\nodejs\node_global\node_modules\marked\bin\marked
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\jsonwebtoken requires joi@'^6.10.1' but will load
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\joi,
npm WARN unmet dependency which is version 9.1.0
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\node_modules\rimraf requires glob@'^7.0.5' but will load
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\node_modules\glob,
npm WARN unmet dependency which is version 4.5.3
marked@0.3.6 F:\Program Files\nodejs\node_global\node_modules\marked
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\jsonwebtoken requires joi@'^6.10.1' but will load
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\joi,
npm WARN unmet dependency which is version 9.1.0
npm WARN unmet dependency F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\node_modules\rimraf requires glob@'^7.0.5' but will load
npm WARN unmet dependency F:\Program Files\nodej
更新了npm的版本
C:\Users\dell>npm -v
2.15.1
C:\Users\dell>npm -v
3.10.8
3
再次npm install –global –production windows-build-tools
末端出现:
F:\Program Files\nodejs\node_global
`-- windows-build-tools@0.6.0
`-- nugget@2.0.1
`-- request@2.75.0
`-- http-signature@1.1.1
`-- sshpk@1.10.1
+-- dashdash@1.14.0
| `-- assert-plus@1.0.0
`-- getpass@0.1.6
`-- assert-plus@1.0.0
已经没有错误,安装成功了
4
安装gyp
C:\WINDOWS\system32>npm install gyp -g
F:\Program Files\nodejs\node_global
`-- gyp@0.5.0
+-- gyp-conditions@0.0.4
| `-- ometajs@3.2.4
| +-- coa@0.3.9
| +-- q@0.8.12
| `-- uglify-js@1.3.5
+-- gyp-expansions@0.0.2
+-- gyp-load@0.5.0
| `-- jsonic-ometajs@0.0.0
| `-- json-ometajs@0.0.1
`-- gyp-merge@0.2.1
测试gyp是否安装成功,成功!
C:\WINDOWS\system32>node
> require ('gyp')
[Function: gyp]
>
5再次安装bcrypt
F:\Program Files\nodejs\node_global\node_modules\bcrypt>if not defined npm_config_node_gyp (node "F:\Program Files\nodejs\node_global\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not f
ind WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid vers
ion number. [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
cl ?
CL : Command line warning D4024: unrecognized source file type '?', object file assumed [F:\Program Files\nodejs\node
_global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:?.exe
?
LINK : fatal error LNK1104: cannot open file "?.exe" [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\b
crypt_lib.vcxproj]
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 (F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd F:\Program Files\nodejs\node_global\node_modules\bcrypt
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt" "-g"
npm ERR! node v4.4.4
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@0.8.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.7 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\WINDOWS\system32\npm-debug.log
依旧错误,但是错误原因有些改变,直接看err,还是有版本原因等错误
查找参看资料
更新node
还需要node-gyp rebulid
6 node-gyp 错误是没有找到python,但是我之前是安装过python的,查找python已经找不到- -莫名其妙 失败。。。换个思路先装更新node
node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@4.4.4 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (F:\Program Files\nodejs\node_global\node_modules\node-gyp\lib\configure.js:449:14)
gyp ERR! stack at F:\Program Files\nodejs\node_global\node_modules\node-gyp\lib\configure.js:404:11
gyp ERR! stack at F:\Program Files\nodejs\node_global\node_modules\node-gyp\node_modules\graceful-fs\polyfills.js:264:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\dell
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
7 更新node http://www.tuicool.com/articles/IRj6r2e
windows下安装Node一般选择 Windows Installer (.msi) 或者 Windows Binary (.exe) ,更新的方式就是 覆盖安装 :直接 下载 目标版本的msi或者exe,在原安装目录覆盖安装即可. 已经安装成功了。一定要安装偶数位的稳定版本。
python我又重新安装了2.7.x的版本。
8再次测试安装bcrypt
F:\Users\dell\Documents\SourceTree\crm>npm install bcrypt -g
> bcrypt@0.8.7 install F:\Program Files\nodejs\node_global\node_modules\bcrypt
> node-gyp rebuild
F:\Program Files\nodejs\node_global\node_modules\bcrypt>if not defined npm_config_node_gyp (node "F:\Program Files\nodejs\node_global\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not fi
nd WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid versio
n number. [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
cl ?
CL : Command line warning D4024: unrecognized source file type '?', object file assumed [F:\Program Files\nodejs\node_
global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:?.exe
?
LINK : fatal error LNK1104: cannot open file "?.exe" [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bc
rypt_lib.vcxproj]
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 (F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd F:\Program Files\nodejs\node_global\node_modules\bcrypt
gyp ERR! node -v v4.6.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt" "-g"
npm ERR! node v4.6.0
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@0.8.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.7 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\Users\dell\Documents\SourceTree\crm\npm-debug.log
我遇到了很大的困难,gyp已经安装成功,windows需要的python vs2015 .Net 我都有安装,但是还是报错
红色报错的是这句话
LINK : fatal error LNK1104: cannot open file "?.exe" [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bc
rypt_lib.vcxproj]
因此,我开始google。我发帖询问:
https://github.com/nodejs/node-gyp/issues/1034
我查找了vs2015目录下的cl.exe 找不到
百度。。
http://www.tuicool.com/articles/zUFja2 配置了path和include,尽量是有的路径都配置了,有的没有就没配置。
再次测试:错误不变。
后来。我尝试了,重新安装visual studio 2015(update 1),安装完成后测试错误不变。
打开vs2015->文件->新建->项目->vc++->安装适于c++的什么。。(有两个选项,我选择了适合win10的了)
安装了一天。。。再次测试成功(虽然有黄色警告但是是成功啦~)
希望我的这篇详细记述对大家有帮助,有问题多尝试!!~~
总的来说还是按照官网提示来做。
C:\Users\dell>npm install bcrypt -g
> bcrypt@0.8.7 install F:\Program Files\nodejs\node_global\node_modules\bcrypt
> node-gyp rebuild
F:\Program Files\nodejs\node_global\node_modules\bcrypt>if not defined npm_config_node_gyp (node "F:\Program Files\nodejs\node_global\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
blowfish.cc
bcrypt.cc
bcrypt_node.cc
win_delay_load_hook.cc
..\src\bcrypt.cc(232): warning C4267: “=”: 从“size_t”转换到“unsigned char”,可能丢失数据 [F:\Program Files\nodejs\node_global\node
_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(76): warning C4244: “参数”: 从“ssize_t”转换到“unsigned char”,可能丢失数据 [F:\Program Files\nodejs\node_globa
l\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(229): warning C4267: “初始化”: 从“size_t”转换到“int”,可能丢失数据 [F:\Program Files\nodejs\node_global\node_mo
dules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(230): warning C4267: “初始化”: 从“size_t”转换到“int”,可能丢失数据 [F:\Program Files\nodejs\node_global\node_mo
dules\bcrypt\build\bcrypt_lib.vcxproj]
正在创建库 F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\Release\bcrypt_lib.lib 和对象 F:\Program Files\nod
ejs\node_global\node_modules\bcrypt\build\Release\bcrypt_lib.exp
正在生成代码
已完成代码的生成
bcrypt_lib.vcxproj -> F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\Release\\bcrypt_lib.node
F:\Program Files\nodejs\node_global
`-- bcrypt@0.8.7
C:\Users\dell>node
> require ('bcrypt')
{ genSaltSync: [Function],
genSalt: [Function],
hashSync: [Function],
hash: [Function],
compareSync: [Function],
compare: [Function],
getRounds: [Function] }
>
错误:
npm install bcrypt -g
/
> bcrypt@0.8.7 install F:\Program Files\nodejs\node_global\node_modules\bcrypt
> node-gyp rebuild
F:\Program Files\nodejs\node_global\node_modules\bcrypt>if not defined npm_config_node_gyp (node "F:\Program Files\nodejs\node_global\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not fi
nd WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid versio
n number. [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
cl ?
CL : Command line warning D4024: unrecognized source file type '?', object file assumed [F:\Program Files\nodejs\node_
global\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:?.exe
?
LINK : fatal error LNK1104: cannot open file "?.exe" [F:\Program Files\nodejs\node_global\node_modules\bcrypt\build\bc
rypt_lib.vcxproj]
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 (F:\Program Files\nodejs\node_global\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd F:\Program Files\nodejs\node_global\node_modules\bcrypt
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "F:\\Program Files\\nodejs\\node.exe" "F:\\Program Files\\nodejs\\node_global\\node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt" "-g"
npm ERR! node v4.4.4
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@0.8.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\Users\dell\Documents\SourceTree\crm\npm-debug.log