【发布时间】:2023-03-17 02:24:01
【问题描述】:
我设置了一个 Firebase 项目来创建一些基本的 Firebase 函数。
在我使用 TypeScript 的项目中
按照Firebase official documentation,我创建了我的项目。
最后一步,firebase deploy --only functions,tsc 命令出错。
$ firebase deploy --only functions
=== Deploying to ‘my-project’…
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /path/to/functions
> tslint --project tsconfig.json
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build /path/to/functions
> tsc
node_modules/firebase-functions/lib/function-builder.d.ts(60,95): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,96): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,116): error TS1005: ';' expected.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build 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! /some/path/.npm/_logs/2019-02-03T00_10_30_573Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
Having trouble? Try firebase deploy --help
似乎某些 Firebase 库代码没有通过 tsc 编译/转译步骤。
我正在寻找使此部署步骤通过的方法。
我遵循了this GitHub issue 给出的建议,其中包括:
- 将
--skipLibCheck添加到tsc命令 - 将
skipLibCheck添加到项目生成的functions/tsconfig.json - 将
isolateModules添加到functions/tsconfig.json - 将
./functions/node_modules/@types添加到functions/tsconfig.json文件中的typeRoots数组中。 - 在
functions/tsconfig.json中添加dom到compilerOptions.lib
以上步骤都不适合我。
如何才能成功部署到 Firebase?
【问题讨论】:
-
嗨 Rick,你是怎么解决这个问题的?如下更改版本效果不佳。你设法解决了这个问题吗?谢谢!!
-
一年半前,成功了。查看接受的答案,升级到最新的 typescript 版本,清除缓存并重试,这些都是我会做的事情。
标签: node.js typescript firebase google-cloud-functions firebase-cli