windows 无法安装grpc npm软件包

30byixjq  于 2022-12-24  发布在  Windows
关注(0)|答案(7)|浏览(245)

grpc npm-package有问题,当我运行npm i时,它的开头是:

> grpc@1.24.2 install C:\RELOG\relog\node_modules\grpc
> node-pre-gyp install --fallback-to-build --library=static_library

那么以**开头的node-gyp,**就有很多错误:

PS C:\RELOG\relog> npm i fcm-node                                                                                                                                                                                                            
> grpc@1.24.2 install C:\RELOG\relog\node_modules\grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for grpc@1.24.2 and node@12.16.2 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error connect ETIMEDOUT 104.28.23.74:443
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  win_delay_load_hook.cc
  WINDOWS_BUILD_WARNING.vcxproj -> C:\RELOG\relog\node_modules\grpc\build\Release\\WINDOWS_BUILD_WARNING.node
  address_sorting.c
  address_sorting_posix.c
  address_sorting_windows.c
  win_delay_load_hook.cc
  address_sorting.vcxproj -> C:\RELOG\relog\node_modules\grpc\build\Release\\libaddress_sorting.lib
  ares__close_sockets.c
  ares__get_hostent.c
  ares__read_line.c
  ares__timeval.c
  ares_cancel.c
  ares_create_query.c
  ares_data.c
  ares_destroy.c
  ares_expand_name.c
  ares_expand_string.c
  ares_fds.c
  ares_free_hostent.c
  ares_free_string.c
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\cares\cares\ares__get_hostent.c(141,32): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnin
gs [C:\RELOG\relog\node_modules\grpc\build\ares.vcxproj]
  ares_getenv.c
  ares_gethostbyaddr.c
  ares_gethostbyname.c
  ares_getnameinfo.c
  ares_getopt.c
  ares_getsock.c
  ares_init.c
  ares_library_init.c
  ares_llist.c
  ares_mkquery.c
  ares_nowarn.c
  ares_options.c
  ares_parse_a_reply.c
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\cares\cares\ares_gethostbyname.c(275,32): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warni
ngs [C:\RELOG\relog\node_modules\grpc\build\ares.vcxproj]
  ares_parse_aaaa_reply.c
  ares_parse_mx_reply.c
  ares_parse_naptr_reply.c
  ares_parse_ns_reply.c
  ares_parse_ptr_reply.c
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\cares\cares\ares_init.c(2421,18): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings [C:\
RELOG\relog\node_modules\grpc\build\ares.vcxproj]
  ares_parse_soa_reply.c
  ares_parse_srv_reply.c
  ares_parse_txt_reply.c
  ares_platform.c
  ares_process.c
  ares_query.c
  ares_search.c
  ares_send.c
  ares_strcasecmp.c
  ares_strdup.c
  ares_strerror.c
  ares_strsplit.c
  ares_timeout.c
  ares_version.c
  ares_writev.c
  bitncmp.c
  inet_net_pton.c
  inet_ntop.c
  windows_port.c
  win_delay_load_hook.cc
  ares.vcxproj -> C:\RELOG\relog\node_modules\grpc\build\Release\\libares.lib
  err_data.c
  a_bitstr.c
  a_bool.c
  a_d2i_fp.c
  a_dup.c
  a_enum.c
  a_gentm.c
  a_i2d_fp.c
  a_int.c
  a_mbstr.c
  a_object.c
  a_octet.c
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(147,1): warning C4005: 'OPENSSL_VERSION_NUMBER': macro redefinition (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\no
de_modules\grpc\build\boringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\opensslv.h(42): message : see previous definition of 'OPENSSL_VERSION_NUMBER' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\no
de_modules\grpc\build\boringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\e_os2.h(171,1): warning C4005: 'OPENSSL_EXPORT': macro redefinition (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modules
\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(182): message : see previous definition of 'OPENSSL_EXPORT' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modul
es\grpc\build\boringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\ossl_typ.h(91,26): error C2371: 'EVP_MD': redefinition; different basic types (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\no
de_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(304): message : see declaration of 'EVP_MD' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modules\grpc\build\bo
ringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\ossl_typ.h(92,30): error C2371: 'EVP_MD_CTX': redefinition; different basic types (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relo
g\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(303): message : see declaration of 'EVP_MD_CTX' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modules\grpc\buil
d\boringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\ossl_typ.h(100,34): error C2371: 'EVP_ENCODE_CTX': redefinition; different basic types (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG
\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(308): message : see declaration of 'EVP_ENCODE_CTX' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modules\grpc\
build\boringssl.vcxproj]
C:\Users\crimpyhead\AppData\Local\node-gyp\Cache\12.16.2\include\node\openssl\crypto.h(231,3): error C2371: 'CRYPTO_THREADID': redefinition; different basic types (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\r
elog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\third_party\boringssl\include\openssl\base.h(231): message : see declaration of 'CRYPTO_THREADID' (compiling source file ..\deps\grpc\src\boringssl\err_data.c) [C:\RELOG\relog\node_modules\grpc
\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(33,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(34,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(35,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(36,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(37,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(38,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(39,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(40,1): error C2065: 'ERR_LIB_PKCS8': undeclared identifier [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(40,1): error C2057: expected constant expression [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(40,1): error C2466: cannot allocate an array of constant size 0 [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(41,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(42,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(43,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(44,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(45,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]
C:\RELOG\relog\node_modules\grpc\deps\grpc\src\boringssl\err_data.c(46,1): error C2118: negative subscript [C:\RELOG\relog\node_modules\grpc\build\boringssl.vcxproj]

最后它显示了这一点:

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=C:\\RELOG\\relog\\node_modules\\grpc\\src\\node\\extension_binary\\node-v72-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\RELOG\\relog\\node_modules\\grpc\\src\\node\\extension_binary\\node-v72-win32-x64-unknown" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\RELOG\relog\node_modules\grpc
gyp ERR! node -v v12.16.2
gyp ERR! node-gyp -v v5.1.0
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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\RELOG\relog\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\RELOG\relog\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\RELOG\relog\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\RELOG\\relog\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd C:\RELOG\relog\node_modules\grpc
node-pre-gyp ERR! node -v v12.16.2
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\RELOG\relog\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\RELOG\relog\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.
npm WARN leaflet-textpath@1.2.3 requires a peer of leaflet@^1.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN leaflet.markercluster@1.4.1 requires a peer of leaflet@~1.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-leaflet@1.9.1 requires a peer of leaflet@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-tooltip@3.11.6 requires a peer of react@>=^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-tooltip@3.11.6 requires a peer of react-dom@>=^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-visjs-timeline@1.6.0 requires a peer of vis-timeline@^5.x but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: grpc@1.24.2 (node_modules\grpc):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: grpc@1.24.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

我有一个Windows 10 VS 2017与开发C++ python2.7添加到路径这里包含的每一件事https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#environment-setup-and-configuration
另外,我试过单独安装grpc npm i grpc。但是它给出了同样的错误。

7kqas0il

7kqas0il1#

对我来说,解决方案是在全球范围内安装grpc。

npm install grpc -g
lstz6jyr

lstz6jyr2#

我不能在windows中安装/运行我的项目。所以解决方案是安装WSL。

f2uvfpb9

f2uvfpb93#

今天对我有效的是从源代码构建它,

npm install grpc --build-from-source
lf3rwulv

lf3rwulv4#

对于那些有这个错误,这是因为节点版本,你必须使用一个较旧的版本.
以这个存储库https://github.com/Jeff-Tian/uni-orders为例,对于节点18,我得到了相同的错误:

yarn start
yarn run v1.22.15
$ cp src/orders/orders.proto dist/orders/orders.proto && nest start
[Nest] 68342   - 08/02/2022, 2:47:32 PM   [PackageLoader] The "grpc" package is missing. Please, make sure to install this library ($ npm install grpc) to take advantage of ServerGrpc.

但是对于节点16,它工作得很好:

yarn run v1.22.19
$ cp src/orders/orders.proto dist/orders/orders.proto && nest start
[Nest] 71355   - 08/02/2022, 2:50:31 PM   [NestFactory] Starting Nest application...
[Nest] 71355   - 08/02/2022, 2:50:31 PM   [InstanceLoader] ClientsModule dependencies initialized +103ms
[Nest] 71355   - 08/02/2022, 2:50:31 PM   [InstanceLoader] HttpModule dependencies initialized +1ms
[Nest] 71355   - 08/02/2022, 2:50:31 PM   [InstanceLoader] ShoppingCartModule dependencies initialized +0ms
[Nest] 71355   - 08/02/2022, 2:50:31 PM   [InstanceLoader] ConfigHostModule dependencies initialized +1ms
hgb9j2n6

hgb9j2n65#

仅在我使用节点版本8.16.2时有效

eit6fx6z

eit6fx6z6#

请尝试以下步骤解决此问题。

  • 删除node_modules文件夹。
  • 使用以下命令安装grpc
npm install grpc
  • 使用以下命令安装其他依赖项
npm install --force
  • 如果在项目中遇到与节点sass相关的错误,请使用以下命令解决该问题。
npm uninstall node-sass
npm install node-sass@4.14.1

jvlzgdj9

jvlzgdj97#

对我有效的解决方案是删除 * package-lock.js * 中包含grpc的位置,然后运行npm install

相关问题