首页 > 解决方案 > 对 async/await 中的 google eslint 错误的操作

问题描述

我已将一些示例录音上传到 firebase 云存储,然后我尝试使用 SSML 将这些录音包含在 google 操作语音中。但我面临的问题是,由于 eslint 错误,我无法将云功能部署到 firebase,该错误显示在 async conv对象旁边。它说Parsing error: Unexpected token conv eslint 我正在关注这篇中等帖子https://medium.com/google-developers/using-cloud-storage-for-firebase-for-hosting-rich-media-in-your -actions-a838977eb758用于实施,但它不起作用。

以下是错误的完整描述:部署函数运行命令:npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint /home/nish/Documents/Projects/Voice/functions
> eslint .


/home/nish/Documents/Projects/Voice/functions/index.js
17:44  error  Parsing error: Unexpected token conv

✖ 1 problem (1 error, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/nish/.npm/_logs/2019-04-02T18_17_17_639Z- 
debug.log

Error: functions predeploy error: Command terminated with non-zero exit code1

这是代码

const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
const bucket = admin.storage().bucket();
const bucketAccessConfig = {
    action: "read",
    expires: Date.now() + 1000 * 60 * 60
};

app.intent("Default Welcome Intent", async conv => {
    // eslint-disable-line no-use-before-define
    let intentName = "Default_Welcome_Intent";
    Path = `${intentName}/${Math.floor(Math.random() * 4) + 1}.ogg`;
    const soundFileRef = bucket.file(Path);
    const [soundUrl] = await soundFileRef.getSignedUrl(bucketAccessConfig);
    // console.log(Path);
    // console.log(storage);
    conv.ask(`<speak><audio src=${soundUrl}/></speak>`);
});

标签: google-cloud-storagegoogle-cloud-functionseslintactions-on-google

解决方案


推荐阅读