代码之家  ›  专栏  ›  技术社区  ›  Emeric

错误TS2304:部署云函数firebase时找不到名称“Element”

  •  0
  • Emeric  · 技术社区  · 6 年前

    我正在构建一个Angular+Firebase web应用程序,由于一些复杂的查询,我开始从Firebase中寻找云函数。

    MyProject
       |__ node_modules
       |__ src (with app and my complete project)
       |__ some files like tsconfig.json
    

    我遵循了经典教程: https://firebase.google.com/docs/functions/get-started

    MyProject
       |__ node_modules
       |__ src (with app and my complete project)
       |__ some files like tsconfig.json
       |__ functions
               |__ node_modules
               |__ src
    

    但使用firebase deploy时出现问题--仅限函数:

    i  deploying functions
    Running command: npm --prefix "%RESOURCE_DIR%" run lint
    
    > functions@ lint E:\Travail\wamp64\www\WhoAmI\WhoAmI\functions
    > tslint --project tsconfig.json
    
    Running command: npm --prefix "%RESOURCE_DIR%" run build
    
    > functions@ build E:\Travail\wamp64\www\WhoAmI\WhoAmI\functions
    > tsc
    
    ../node_modules/@types/jquery/index.d.ts(191,29): error TS2304: Cannot find name 'XMLHttpRequest'.
    ../node_modules/@types/jquery/index.d.ts(512,41): error TS2304: Cannot find name 'Event'.
    ../node_modules/@types/jquery/index.d.ts(517,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(527,21): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(552,20): error TS2304: Cannot find name 'Event'.
    ../node_modules/@types/jquery/index.d.ts(562,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(582,13): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(944,34): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(952,15): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(960,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(999,36): error TS2304: Cannot find name 'Document'.
    ../node_modules/@types/jquery/index.d.ts(1046,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1054,19): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1061,19): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1070,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1078,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1087,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1096,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1105,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1114,25): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1191,25): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1191,45): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1309,32): error TS2304: Cannot find name 'Window'.
    ../node_modules/@types/jquery/index.d.ts(1316,20): error TS2304: Cannot find name 'Node'.
    ../node_modules/@types/jquery/index.d.ts(1378,29): error TS2304: Cannot find name 'XMLDocument'.
    ../node_modules/@types/jquery/index.d.ts(1402,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(1412,39): error TS2304: Cannot find name 'HTMLElement'.
    ../node_modules/@types/jquery/index.d.ts(1422,39): error TS2304: Cannot find name 'Document'.
    ../node_modules/@types/jquery/index.d.ts(1437,70): error TS2304: Cannot find name 'XMLHttpRequest'.
    ../node_modules/@types/jquery/index.d.ts(1472,69): error TS2304: Cannot find name 'XMLHttpRequest'.
    ../node_modules/@types/jquery/index.d.ts(1482,115): error TS2304: Cannot find name 'XMLHttpRequest'.
    ../node_modules/@types/jquery/index.d.ts(3075,14): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3119,34): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3119,42): error TS2304: Cannot find name 'DocumentFragment'.
    ../node_modules/@types/jquery/index.d.ts(3119,59): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3126,57): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3135,35): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3135,43): error TS2304: Cannot find name 'DocumentFragment'.
    ../node_modules/@types/jquery/index.d.ts(3135,60): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3142,58): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3150,35): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3159,35): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3159,43): error TS2304: Cannot find name 'DocumentFragment'.
    ../node_modules/@types/jquery/index.d.ts(3159,60): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3166,58): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3197,38): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3197,46): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3205,39): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3205,47): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3214,36): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3214,44): error TS2304: Cannot find name 'DocumentFragment'.
    ../node_modules/@types/jquery/index.d.ts(3214,61): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3221,59): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3229,36): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3245,37): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3253,42): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3253,50): error TS2304: Cannot find name 'Text'.
    ../node_modules/@types/jquery/index.d.ts(3260,29): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3287,16): error TS2304: Cannot find name 'HTMLElement'.
    ../node_modules/@types/jquery/index.d.ts(3301,34): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3316,37): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3331,39): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3346,38): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3354,25): error TS2304: Cannot find name 'HTMLElement'.
    ../node_modules/@types/jquery/index.d.ts(3360,12): error TS2304: Cannot find name 'HTMLElement'.
    ../node_modules/@types/jquery/index.d.ts(3373,35): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3386,22): error TS2304: Cannot find name 'HTMLElement'.
    ../node_modules/@types/jquery/index.d.ts(3395,37): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3402,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3440,41): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3454,22): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3463,39): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3498,43): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3505,21): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3527,19): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3555,20): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3570,39): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3598,47): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3631,25): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3654,40): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3661,19): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3661,27): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3707,28): error TS2304: Cannot find name 'Element'.
    ../node_modules/@types/jquery/index.d.ts(3748,25): error TS2304: Cannot find name 'Element'.
    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.
    

    你知道吗?我做错什么了吗?

    版本: “firebase管理”:“~6.0.0” firebase CLI:4.2.1

    1 回复  |  直到 6 年前
        1
  •  1
  •   Doug Stevenson    6 年前

    你的angular项目和functions项目应该在不同的文件夹中。现在您已经将它们组合在一起了,Firebase CLI正在尝试lint并将您的web代码部署到云函数中,这是行不通的。

    MyProject
      /angular
        /src
        /node_modules
      /functions
        /src
        /node_modules