Firebase部署后-错误:找不到模块 [英] After Firebase deploy - Error: cannot find module

查看:77
本文介绍了Firebase部署后-错误:找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本地Firebase服务器上运行Node.js函数不会导致以下错误,但是当我执行 firebase deploy 并尝试在已部署的服务器上运行相同的函数时,出现此错误在Firebase功能日志中(在Web Firebase控制台中):

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):

错误:找不到模块'@ google-cloud/speech'

我错过了什么?(我可以在已部署的服务器上运行其他功能,但是我对此并不陌生,不知道我是否做过其他事情,或者此npm模块是否有所不同.)

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.)

推荐答案

Cloud Functions仅将您已声明为依赖项的模块安装在 package.json 中的模块(及其依赖项)中, functions 文件夹.如果模块未在此处显示,则您将无法直接从代码中访问它.请确保从您的 functions 文件夹中运行 @ google-cloud/speech ,以便在开发和部署时都可以使用它.

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.

这篇关于Firebase部署后-错误:找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆