尝试在nodejs中安装hiredis,我收到此错误。我在Google上找不到任何有用的内容。有谁有这个问题?我正在使用最新版本的nodejs。
C:\Users\berthsa\new>npm install hiredis --save
npm http GET https://registry.npmjs.org/redis
npm http GET https://registry.npmjs.org/hiredis
npm http 304 https://registry.npmjs.org/redis
npm http 304 https://registry.npmjs.org/hiredis
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
> hiredis@0.1.16 install C:\Users\berthsa\new\node_modules\hiredis
> node-gyp rebuild
C:\Users\berthsa\new\node_modules\hiredis>node "C:\Users\berthsa\AppData\Roaming
\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp
.js" rebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
hiredis.c
async.c
net.c
sds.c
..\..\deps\hiredis\net.c(35): fatal error C1083: Cannot open include file: 'sys
/socket.h': No such file or directory [C:\Users\berthsa\new\node_modules\hiredi
s\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\async.c(35): fatal error C1083: Cannot open include file: 's
trings.h': No such file or directory [C:\Users\berthsa\new\node_modules\hiredis
\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\hiredis.c(35): fatal error C1083: Cannot open include file:
'unistd.h': No such file or directory [C:\Users\berthsa\new\node_modules\hiredi
s\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(45): error C2054:
expected '(' to follow 'inline' (..\..\deps\hiredis\sds.c) [C:\Users\berthsa\ne
w\node_modules\hiredis\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(45): error C2085:
'sdslen' : not in formal parameter list (..\..\deps\hiredis\sds.c) [C:\Users\be
rthsa\new\node_modules\hiredis\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(45): error C2143:
syntax error : missing ';' before '{' (..\..\deps\hiredis\sds.c) [C:\Users\bert
hsa\new\node_modules\hiredis\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(50): error C2054:
expected '(' to follow 'inline' (..\..\deps\hiredis\sds.c) [C:\Users\berthsa\ne
w\node_modules\hiredis\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(50): error C2085:
'sdsavail' : not in formal parameter list (..\..\deps\hiredis\sds.c) [C:\Users\
berthsa\new\node_modules\hiredis\build\deps\hiredis.vcxproj]
c:\users\berthsa\new\node_modules\hiredis\deps\hiredis\sds.h(50): error C2143:
syntax error : missing ';' before '{' (..\..\deps\hiredis\sds.c) [C:\Users\bert
hsa\new\node_modules\hiredis\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(53): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\d
eps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(83): warning C4267: 'initializing' : conversion from '
size_t' to 'int', possible loss of data [C:\Users\berthsa\new\node_modules\hire
dis\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(104): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(122): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(123): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(135): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(136): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(157): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(158): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(179): warning C4013: 'va_copy' undefined; assuming ext
ern returning int [C:\Users\berthsa\new\node_modules\hiredis\build\deps\hiredis
.vcxproj]
..\..\deps\hiredis\sds.c(214): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(215): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(225): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(229): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(237): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(245): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(246): warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\build\
deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(251): warning C4267: 'initializing' : conversion from
'size_t' to 'int', possible loss of data [C:\Users\berthsa\new\node_modules\hir
edis\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(257): warning C4267: 'initializing' : conversion from
'size_t' to 'int', possible loss of data [C:\Users\berthsa\new\node_modules\hir
edis\build\deps\hiredis.vcxproj]
..\..\deps\hiredis\sds.c(270): warning C4267: 'return' : conversion from 'size_
t' to 'int', possible loss of data [C:\Users\berthsa\new\node_modules\hiredis\b
uild\deps\hiredis.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\berthsa\AppData\Roaming\npm\
node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\berthsa\\AppData\\Roaming\\npm\\node_modules
\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\berthsa\new\node_modules\hiredis
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
答案 0 :(得分:1)
如果要在Windows上安装hiredis,并且满足所有必需的先决条件(如Visual Studio),则应在Windows支持下安装fork of hiredis-node。
在这种情况下,您必须直接从github tarball安装它:
npm install https://github.com/fuwaneko/hiredis-node/tarball/v0.1.14