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):
在本地Firebase服务器中运行Node.js功能不会导致下面的错误,但是当我执行firebase部署并尝试在部署的服务器上运行相同的功能时,我在Firebase功能日志中遇到此错误(在Web Firebase中)安慰):
Error: Cannot find module '@google-cloud/speech'
错误:无法找到模块'@ 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.)
我错过了什么? (我可以在已部署的服务器上运行其他一些功能,但我是新手,并且不知道我是否做了不同的事情,或者这个npm模块有什么不同。)
1 个解决方案
#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.
云函数只会在您的package.json(及其依赖项)中的functions文件夹中安装已声明为依赖项的模块。如果模块没有显示在那里,您将无法直接从您的代码访问它。确保从您的函数文件夹运行@ google-cloud / speech,以便您可以在开发期间和部署时使用它。
#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.
云函数只会在您的package.json(及其依赖项)中的functions文件夹中安装已声明为依赖项的模块。如果模块没有显示在那里,您将无法直接从您的代码访问它。确保从您的函数文件夹运行@ google-cloud / speech,以便您可以在开发期间和部署时使用它。