【问题标题】:Grpc error while installing Firebase for React为 React 安装 Firebase 时出现 Grpc 错误
【发布时间】:2018-10-17 10:44:52
【问题描述】:

我已经尝试修复此错误 2 天了。我所做的就是:

  1. create-react-app 应用名称
  2. cd 应用名称
  3. npm install firebase --save(这是未能正确安装的部分)

这些是我尝试过的主要修复:

  • 安装最新版本的 Python 3 并将其添加到 windows 路径变量中。
  • 手动下载 grpc 并添加到项目中。
  • 已将节点更新到 v10+。

我还尝试了其他不值得一提的小事,但并没有什么不同。他们都没有工作。我尝试了多个干净的反应应用程序,所以反应也不是问题。

C:\Users\Future\Desktop\react-turbo>npm i firebase --save

> grpc@1.10.1 install C:\Users\Future\Desktop\react-turbo\node_modules\grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.10.1/node-v64-win32-x64-unknown.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.10.1 and node@10.0.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Future\AppData\Local\Programs\Python\Python36-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:149:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=C:\\Users\\Future\\Desktop\\react-turbo\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\Users\\Future\\Desktop\\react-turbo\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown"
gyp ERR! cwd C:\Users\Future\Desktop\react-turbo\node_modules\grpc
gyp ERR! node -v v10.0.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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --library=static_library --module=C:\Users\Future\Desktop\react-turbo\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\Future\Desktop\react-turbo\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Future\Desktop\react-turbo\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:947:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:236:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Future\\Desktop\\react-turbo\\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:\Users\Future\Desktop\react-turbo\node_modules\grpc
node-pre-gyp ERR! node -v v10.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.7.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 configure --fallback-to-build --library=static_library --module=C:\Users\Future\Desktop\react-turbo\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\Future\Desktop\react-turbo\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown' (1)
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.10.1 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.10.1 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\Future\AppData\Roaming\npm-cache\_logs\2018-05-07T15_01_00_277Z-debug.log

【问题讨论】:

    标签: reactjs firebase


    【解决方案1】:

    我不知道这是否相关,但我也遇到了类似的错误。 我正在尝试使用 expo 安装 firebase(按照文档中的建议)

    expo install firebase

    这对我来说是失败的。我注意到这个问题与我的 package-lock.json 有关,其中添加了 node-pre-gyp。浪费了一些时间,但当我进行 npm 安装(而不是 expo 安装)时,问题终于解决了 希望这对未来的人们有所帮助。

    npm install firebase --save

    【讨论】:

      【解决方案2】:

      我需要将节点从 10.12 降级到 8.11

      node -v
      

      v10.12.0

      npm install -g n
      n 8.11.1
      mode -v
      

      v8.11.1

      【讨论】:

        【解决方案3】:

        我建议不要安装node 最新版本(可能并非所有库都支持)尝试使用v8.11 稳定版本。

        然后有几个动作/技巧来处理这件事:

        1. 您可能正在使用Windows 10,因此请尝试禁用您的防病毒软件,然后重试。如果在Linux 上,请尝试在启动时使用命令sudo
        2. 也检查一下:unable to install firebase tools cli using windows 10
        3. 还有这个:Error with npm install - a pre-gyp error

        其他信息 关于学习Firebase,这些也可能对您有所帮助:

        https://medium.com/quick-code/how-to-integrate-react-redux-and-firebase-in-3-simple-steps-c44804a6af38

        https://www.codementor.io/yurio/all-you-need-is-react-firebase-4v7g9p4kf

        【讨论】:

        • 问题要么是 Node,因为我只有 v10+ 版本,要么是标准的 Windows 防病毒软件,甚至可能两者兼有 :-) 禁用了防病毒软件并安装了 Node LTS v8.11,现在它可以工作了。你是一个救生员,再次感谢你 Muhammad =] 我永远不会忘记这一点。现在我可以继续开发我的网络应用程序了,这还有很长的路要走。
        • 只是更新节点 v.10 现在对我来说很好,这似乎是 v.11+ 的问题
        猜你喜欢
        • 2017-05-07
        • 2018-12-16
        • 2021-03-15
        • 2020-07-23
        • 1970-01-01
        • 2020-11-22
        • 2022-01-23
        • 2021-11-30
        • 1970-01-01
        相关资源
        最近更新 更多