错误TS2304:部署云功能Firebase时找不到名称“元素”

时间:2018-09-12 18:54:20

标签: angular firebase firebase-realtime-database google-cloud-functions

我正在构建Angular + Firebase Web应用程序,由于一些复杂的查询,我开始从firebase寻找Cloud Functions。

我的项目如下:

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 --only功能时出现问题:

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”:“ ^ 5.0.4” “ firebase-functions”:“ ^ 2.0.3” “ firebase-admin”:“〜6.0.0” firebase CLI:4.2.1

1 个答案:

答案 0 :(得分:1)

您的角度项目和功能项目应位于不同的文件夹中。现在,您已经将它们组合在一起,并且Firebase CLI正在尝试整理和将您的Web代码部署到Cloud Functions,这是行不通的。

将两个节点项目完全分开,彼此之间没有重叠,因为它们彼此独立运行:

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