Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: Cannot start emulator

functions: Cannot start emulator. Error: Cannot find module '@google-cloud/functions-emulator/src/config'

This is the error message I get when I try to run functions locally on Mac. My Firebase version is 3.16.0. I tried doing sudo npm install -g @google-cloud/functions-emulator as well. But still no use. Please help.

like image 747
Edison D'souza Avatar asked Dec 07 '17 05:12

Edison D'souza


2 Answers

Working Solution!(OSX) None of the above worked for me. After a long struggle, I found the following solution.

cd my_project/functions

npm install @google-cloud/functions-emulator

Copy @google-cloud/functions-emulator folder generated inside node_modules.

cd /usr/local/lib/node_modules/@google-cloud && open .

Paste the functions-emulator folder here.

In your project's root directory, copy package.json inside functions/node_modules/@google-cloud/functions-emulator

cd /usr/local/lib && open .

Paste the package.json here.

npm install

Hurray! You are good to go. Now go back to your project's root directory and run.

sudo firebase serve --only hosting,functions

And the emulator should start normally.

Note: Do not run sudo npm install -g @google-cloud/functions-emulator since the files will be removed and reinstalled. This is where the installation fails and emulator fails to run.

Hope this helps!

like image 110
Edison D'souza Avatar answered Oct 18 '22 00:10

Edison D'souza


The following worked for me.

  1. npm uninstall -g firebase-tools && npm i -g firebase-tools
  2. npm i --save @google-cloud/firestore
  3. npm i --save @google-cloud/common-grpc
  4. npm i -g @google-cloud/functions-emulator
  5. npm i --save firebase-functions

current package.json snippet

"dependencies": {
    "@google-cloud/common-grpc": "^0.5.3",
    "@google-cloud/firestore": "^0.11.1",
    "firebase-functions": "^0.8.1",
    "firebase-admin": "5.8.1" 
}
like image 31
Kevin Koelzer Avatar answered Oct 18 '22 00:10

Kevin Koelzer