1

Running a Node.js function in the local Firebase server does not result in the error below, but when I do firebase deploy and try to run the same function on the deployed server I get this error in the Firebase Functions log (in the web Firebase console):

Error: Cannot find module '@google-cloud/speech'

What have I missed? (I can run some other functions on the deployed server, but I am new to this and have no idea if I have done something different, or if there is something different about this npm module.)

3
  • 1
    What does your package.json look like? Have you installed that module? Commented Mar 24, 2018 at 0:18
  • @DougStevenson Hm, good question. I can't find the package in package.json, but I believe I have installed it. I have done npm install --save @google-cloud/speech as the instructions say. I just did it once more just to be sure. And. That fixed the problem. It looks like I did not run the install from the functions directory before. (And I don't understand what happened in the local web server case then.) Many thanks. Commented Mar 24, 2018 at 1:24
  • @DougStevenson Do you want to add the answer? Or should I do it? Commented Mar 24, 2018 at 1:25

1 Answer 1

1

Cloud Functions will only install the modules that you've declared as dependencies in your package.json (and their dependencies) in the functions folder. If the module doesn't show up there, you won't be able to access it directly from your code. Be sure to run @google-cloud/speech from your functions folder, so that you can use it both during development an when deployed.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I still do not understand how to activate @google-cloud/speech on the local dev server, but that is another question, I believe.
Typically a module doesn't do anything until you start writing code that accesses it.
:-) That is my experience too. I have posted a new question: stackoverflow.com/questions/49471143/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.