[英]Firebase cloud function local code changes are not reflected in emulators
I am trying to develop API for my apps using Firebase cloud functions.我正在尝试使用 Firebase 云函数为我的应用程序开发 API。
Following this site to use the firebase emulator suite for development and testing locally.跟随本站使用firebase模拟器套件在本地进行开发和测试。
Issue: The changes are not reflected in the locally emulated functions.问题:更改未反映在本地模拟函数中。
Steps:脚步:
index.js:索引.js:
exports.test = functions.https.onRequest(async (request, response) => { response.status(200).send("First"); });
Successfully deployed the test
method.成功部署test
方法。
firebase deploy --only functions:test
In Postman made the following GET request.在 Postman 中发出了如下 GET 请求。
https://us-central1-<project-name>.cloudfunctions.net/test
Result: First结果:第一
Status: 200 OK状态:200 正常
Started the emulators:启动模拟器:
firebase emulators:start --only functions
In Postman made the following GET request.在 Postman 中发出了如下 GET 请求。
http://localhost:5001/<project-name>/us-central1/indexTest
Result: First结果:第一
Status: 200 OK状态:200 正常
Same as the actual deployed function.同实际部署的function。
Changed the function code to:将 function 代码更改为:
exports.test = functions.https.onRequest(async (request, response) => { response.status(200).send("Second"); });
Getting the same result as before when hitting the emulated function in localhost.在本地主机中点击模拟的 function 时得到与以前相同的结果。 The changes are not reflected.不会反映更改。
Also, tried stopping the emulator and starting it again.另外,尝试停止模拟器并重新启动它。 No luck.没有运气。
I had raised an issue in the firebase-tools repo as suggested by DougStevenson.按照 DougStevenson 的建议,我在 firebase-tools 回购中提出了一个问题。 Got the issue resolved with Sam Stern's support.在 Sam Stern 的支持下解决了这个问题。
Posting the solution here for anyone else who gets stuck in the same issue.在此处为陷入同一问题的任何其他人发布解决方案。
Solution:解决方案:
"build": "tsc"
to "build": "tsc -w"
in package.json
if you want to auto-compile after every change.如果您想在每次更改后自动编译, package.json
中的"build": "tsc"
更改为"build": "tsc -w"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.