【发布时间】:2018-08-13 23:24:07
【问题描述】:
我的函数 package.json
...
"dependencies": {
"firebase-admin": "~5.13.0",
"firebase-functions": "^2.0.0",
"puppeteer": "^1.6.2"
},
"engines": {
"node": "8"
}
我的旧非异步函数被部署。但不是我的新异步:
exports.screenshot = async (req, res) => {
const url = "https://google.de"; // req.query.url;
if (!url) {
return res.send('Please provide URL as GET parameter, for example: <a href="?url=https://example.com">?url=https://example.com</a>');
}
const browser = await puppeteer.launch({
args: ["--no-sandbox"]
});
const page = await browser.newPage();
await page.goto(url);
const imageBuffer = await page.screenshot();
await browser.close();
res.set("Content-Type", "image/png");
res.send(imageBuffer);
};
运行时:firebase deploy --only functions:screenshot
我得到了错误:
The following functions are found in your project but do not exist in your local source code:
screenshot(us-central1)
我能做什么?
【问题讨论】:
-
从 Node 7.6 开始支持异步/等待。你在检查脚本吗?
-
linting 没有错误。问题是部署脚本没有检测到它
-
请编辑问题以更具体地显示错误是什么。是否有描述问题的命令行输出?
-
我没有收到任何错误。未部署异步功能(已识别?)
-
您是否在节点脚本的其他任何地方发出
Module.exports?如果是这样,那将覆盖您的个人export
标签: firebase async-await google-cloud-functions