问题描述
我设置了一个 Firebase 项目来创建一些基本的 Firebase 函数.
在我使用 TypeScript 的项目中
I've setup a Firebase project to create some basic Firebase Functions.
In the project I'm using TypeScript
按照 Firebase 官方文档,我创建了我的项目.
Following the Firebase official documentation I created my project.
最后一步,firebase deploy --only functions
,tsc
命令出错.
The last step, firebase deploy --only functions
, gave an error with the tsc
command.
$ 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
编译/转译步骤.我正在寻找使此部署步骤通过的方法.
It seems that some of the Firebase library code does not pass the tsc
compile/transpile step.I'm looking for a way to make this deploy step pass.
我已遵循 此 GitHub 问题 中给出的建议,其中包括:
I've followed the suggestion given at this GitHub issue, which included:
- 将
--skipLibCheck
添加到tsc
命令 - 将
skipLibCheck
添加到项目生成的functions/tsconfig.json
- 将
isolateModules
添加到functions/tsconfig.json
- 将
./functions/node_modules/@types
添加到functions/tsconfig.json
文件中的typeRoots
数组中. - 将
dom
添加到functions/tsconfig.json中的
compilerOptions.lib
- Adding
--skipLibCheck
to thetsc
command - Adding
skipLibCheck
to the project's generatedfunctions/tsconfig.json
- Adding
isolateModules
tofunctions/tsconfig.json
- Adding
./functions/node_modules/@types
to thetypeRoots
array in thefunctions/tsconfig.json
file. - Adding
dom
tocompilerOptions.lib
infunctions/tsconfig.json
以上步骤都不适合我.
如何才能成功部署到 Firebase?
How can I make my deployment to Firebase succeed?
推荐答案
遇到同样的问题,将 typescript 库升级到 3.3.1 版本并执行 npm install 后能够部署.
Ran into same issue, was able to deploy after upgrading typescript library to 3.3.1 version and do npm install.
在 package.json 文件集中开发依赖":{"tslint": "~5.8.0",打字稿":~3.3.1"},
In package.json file set "devDependencies": { "tslint": "~5.8.0", "typescript": "~3.3.1" },
注意:您可以删除帖子中描述的所有更改.
Note: you can remove all changes described in your post.
这篇关于Firebase 部署在 tsc 命令返回错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!