firebase函数错误:grpc_node.node是针对不同的Node.js编译的

时间:2018-01-28 22:36:34

标签: node.js firebase google-cloud-functions firebase-cli

我刚下载并安装了一个较新的节点v8.9.4。

然后,我尝试使用命令在本地运行firebase函数:

firebase serve --only functions --debug

我得到以下节点js版本错误:

functions: Cannot start emulator. Error: The module '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary/grpc_node.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

如何摆脱此错误(我想使用最新的节点版本)

====更新====

我尝试了npm rebuildnpm install,然后再次运行firebase serve --only functions --debug,但我仍然遇到同样的错误。

=====更新2 =====

我尝试删除它抱怨的模块:

rm -rf /usr/local/lib/node_modules/firebase-tools/node_modules/grpc/

然后,运行:

npm install grpc

然后,再次运行firebase serve --only functions --debug,现在我收到错误:

⚠  functions: Cannot start emulator. Error: Cannot find module 'grpc'

似乎它没有做我想做的事情,我现在该怎么办才能摆脱这个新错误???

1 个答案:

答案 0 :(得分:0)

sudo npm install -g grpc --allow-root --unsafe

解决