问题
I just downloaded and installed a newer node v8.9.4.
Then, I try to run firebase functions locally with command:
firebase serve --only functions --debug
I get the following node js version error:
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`).
How can I get rid of this error (I would like to use latest node version)
==== UPDATE ====
I tried both npm rebuild
and npm install
, after that, I run firebase serve --only functions --debug
again, but I still get the same error.
===== UPDATE 2 =====
I tried delete the module it complains about by:
rm -rf /usr/local/lib/node_modules/firebase-tools/node_modules/grpc/
Then, run:
npm install grpc
Then, run firebase serve --only functions --debug
again, now I get error:
⚠ functions: Cannot start emulator. Error: Cannot find module 'grpc'
Seems it doesn't do what I wished, what should I do now to get rid of this new error???
回答1:
Solved by sudo npm install -g grpc --allow-root --unsafe
来源:https://stackoverflow.com/questions/48492104/firebase-functions-error-grpc-node-node-was-compiled-against-a-different-node-j