Node.js Firebase云功能节点8-“;错误:Can';“找不到环境配置”;远程部署时

Node.js Firebase云功能节点8-“;错误:Can';“找不到环境配置”;远程部署时,node.js,typescript,firebase,google-cloud-functions,Node.js,Typescript,Firebase,Google Cloud Functions,我正在用节点8的typescript编写firebase云函数。为了从云功能访问firebase存储桶,我以以下方式在index.ts中初始化了我的CFs,以便在prod和dev firebase项目之间切换: import * as admin from 'firebase-admin' import * as geofunctions from 'geofirestore' if(!process.env.FIREBASE_CONFIG){ throw Error("Can't f

我正在用节点8的typescript编写firebase云函数。为了从云功能访问firebase存储桶,我以以下方式在
index.ts
中初始化了我的CFs,以便在prod和dev firebase项目之间切换:

import * as admin from 'firebase-admin'
import * as geofunctions from 'geofirestore'

if(!process.env.FIREBASE_CONFIG){
    throw Error("Can't find env config")
}

const adminConfig = JSON.parse(process.env.FIREBASE_CONFIG)
const projectId = adminConfig.projectId

const certPath = projectId + '.json'
const bucketUrl = projectId + '.appspot.com'

admin.initializeApp({
    credential: admin.credential.cert(certPath),
    storageBucket: bucketUrl
});
这符合:

这在本地运行时效果良好,例如:
firebase-p dev-service

但是,当我使用
firebase deploy-p dev--only functions
远程部署时,所有函数都会失败,并出现以下错误:

⚠  functions[<<MY FUNCTION NAME>>(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file lib/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: Can't find env config
    at Object.<anonymous> (/srv/lib/index.js:7:11)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at getUserFunction (/worker/worker.js:439:24)
    at loadUserCode (/worker/worker.js:495:18)
你知道我做错了什么吗

"dependencies": {
    "firebase-admin": "^8.5.0",
    "firebase-functions": "^3.2.0",
    "firebase-tools": "^7.3.2",
    ...
},
  "devDependencies": {
    "firebase-functions-test": "^0.1.6",
    "tslint": "^5.12.0",
    "typescript": "^3.6.3"
    ...
  },