###問題と実現したいこと
Cloud Functionsのデプロイをしたいです。
ターミナルでカレントディレクトリを開発のディレクトリに移動させて、
firebase deploy
とコマンドしたのですが、以下のようなエラーが表示されました。
Unexpected tokenのエラーなので記述ミスかと思い、参考のコードと見比べてみたのですが、記述ミスを見つけることはできませんでした。
原因と解決法が分かる方がいれば、ご教授お願いします。
###エラー内容
react
1Error: Error occurred while parsing your function triggers. 2 3/home/tatsumip/tatsumiproject/myapp/functions/src/index.ts:1 4import * as functions from 'firebase-functions'; 5 ^ 6 7SyntaxError: Unexpected token * 8 at Module._compile (internal/modules/cjs/loader.js:723:23) 9 at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) 10 at Module.load (internal/modules/cjs/loader.js:653:32) 11 at tryModuleLoad (internal/modules/cjs/loader.js:593:12) 12 at Function.Module._load (internal/modules/cjs/loader.js:585:3) 13 at Module.require (internal/modules/cjs/loader.js:692:17) 14 at require (internal/modules/cjs/helpers.js:25:18) 15 at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15 16 at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:53:3) 17 at Module._compile (internal/modules/cjs/loader.js:778:30)
###エラーで指摘されたコード(index.ts)
react
1import * as functions from 'firebase-functions'; 2import * as admin from "firebase-admin"; 3admin.initializeApp(); 4const db = admin.firestore(); 5 6const sendResponse = (response: functions.Response, statusCode: number, body: any) => { 7 response.send({ 8 statusCode, 9 body: JSON.stringify(body) 10 }); 11}; 12 13export const addDataset = functions.https.onRequest(async (req: any, res: any) => { 14 if (req.method !== 'POST') { 15 sendResponse(res, 405, {error: "Invalid Request"}) 16 } else { 17 const dataset = req.body; 18 for (const key of Object.keys(dataset)) { 19 const data = dataset[key]; 20 await db.collection('questions').doc(key).set(data) 21 } 22 sendResponse(res, 200, {message: 'Successfully added dataset!'}); 23 } 24});
###開発環境
・Windows10
・WSL
・Linux
・Ubuntu
・bash
・curl v7.68
・nodebrew v8.94
・Node v14.04
・create-react-app
・VisualStuidoCode v1.501
・firebase
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/11/04 04:53