【问题标题】:Error in function deploy to decrease image size when uploaded上传时功能部署错误以减小图像大小
【发布时间】:2019-01-15 15:09:18
【问题描述】:

我正在尝试部署一个函数,以在上传到 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

【问题讨论】:

    标签: typescript firebase google-cloud-functions


    【解决方案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)
    

    【讨论】:

    • 更改后错误仍然存​​在,除了您指出的更改之外,您需要运行命令npm uninstall @google-cloud/storage --save 以便部署不会出现错误。
    猜你喜欢
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    • 2015-05-22
    • 1970-01-01
    • 2014-11-06
    • 1970-01-01
    相关资源
    最近更新 更多