Firebase cloud functionsで.envを追加したらデプロイできなくなった。。Failed to load function definition from source

LINE messaging APIの開発で、typescriptとfirebase cloud functionsを使っています。
そしてLINEのchannelSecretchannelAccessTokenを環境変数にしたくて、こちらを参考に.envファイルを
追加しました。

するとデプロイできなくなりました。。。
どなたか助けてください!

index.ts

typescript

import * as functions from "firebase-functions";import * as line from "@line/bot-sdk";import * as admin from 'firebase-admin';admin.initializeApp();// import { config } from '../.env'; interface Config { channelAccessToken: string; channelSecret: string;} const config: Config = { // ここをprocess.envではなく直接値を入れるとデプロイできる channelAccessToken: process.env.CHANNEL_ACCESS_TOKEN as string, channelSecret: process.env.CHANNEL_SECRET as string};

.env

CHANNEL_ACCESS_TOKEN = 'アクセストークン' CHANNEL_SECRET = 'チャネルシークレット'
% firebase deploy --only functions === Deploying to 'line-bot'... i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > tsc ✔ functions: Finished running predeploy script. i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled... ✔ artifactregistry: required API artifactregistry.googleapis.com is enabled ✔ functions: required API cloudbuild.googleapis.com is enabled ✔ functions: required API cloudfunctions.googleapis.com is enabled i functions: preparing codebase default for deployment i functions: Loaded environment variables from .env. Error: Failed to load function definition from source: Failed to generate manifest from function source: Error: no channel access token

コメントを投稿

0 コメント