我正在尝试部署一个功能,以减小在Firebase存储中上传时的图像大小。
尝试使用以 TypeScript 编写的函数来部署功能时,会发生此错误。
我要执行的功能与下面的功能相同。 https://angularfirebase.com/lessons/image-thumbnail-resizer-cloud-function/
**The following error is displayed:**
λ firebase deploy --only functions
=== Deploying to 'myProject1154'...
i deploying functions
Running command: npm --prefix "functions" run lint
> functions@ lint C:\myApp\functions
> tslint --project tsconfig.json
Running command: npm --prefix "functions" run build
> functions@ build C:\myApp\functions
> tsc
node_modules/@google-cloud/common/build/src/service-object.d.ts(72,45): error TS8020: JSDoc types can only be used inside documentation comments.
node_modules/@google-cloud/common/build/src/service-object.d.ts(72,45): error TS8028: JSDoc '...' may only appear in the last parameter of a signature.
node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/oauth2client.d.ts(291,55): error TS1039: Initializers are not allowed in ambient contexts.
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! C:\Users\LUIZ\AppData\Roaming\npm-cache\_logs\2019-01-15T15_00_31_114Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
答案 0 :(得分:1)
几天前我遇到了同样的问题。您必须使用firebase-admin
中的存储对象,而不是google-cloud/storage
所以我的代码如下:
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
admin.initializeApp(functions.config())
const storage = admin.storage()
然后再
storage.bucket(fileBucket)