Firebase函数为Node_Modules部署查找错误的目录

Kev*_*291 6 firebase google-cloud-functions

在尝试部署我的firebase函数时,我收到了父目录的node_modules的错误,尽管我的firebase函数目录有自己的函数.当我运行"firebase deploy --only functions"时,我非常确定我在我的函数目录中.任何想法为什么它看看父目录???

错误:

    > tsc -p tsconfig.json

../node_modules/@types/highcharts/index.d.ts(53,33): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(186,23): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(187,27): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(188,26): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(189,27): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(623,33): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(635,32): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1360,38): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1374,39): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1385,43): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1404,43): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1431,28): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1437,29): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1463,25): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1468,28): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1478,22): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1488,24): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1495,24): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(1897,29): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(2174,26): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(3383,41): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3394,38): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3409,30): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3442,33): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3451,26): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3458,27): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3556,23): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3564,26): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3572,27): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3580,24): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3588,24): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3596,26): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3604,24): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(3611,33): error TS2304: Cannot find name 'Event'.
../node_modules/@types/highcharts/index.d.ts(6216,20): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(6438,33): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(6448,33): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(6642,26): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/highcharts/index.d.ts(6659,34): error TS2304: Cannot find name 'HTMLElement'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc -p tsconfig.json`
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.
Run Code Online (Sandbox Code Playgroud)

目录结构: 在此输入图像描述

我的Package.json:

    {
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "node_modules/.bin/tsc -p tsconfig.json",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "~5.10.0",
    "firebase-functions": "^0.9.0"
  },
  "devDependencies": {
    "tslint": "^5.8.0",
    "typescript": "^2.5.3"
  },
  "private": true
}
Run Code Online (Sandbox Code Playgroud)

小智 17

有同样的问题,这解决了我在Cloud Functions Firestore中的Firebase-Admin软件包Typescript错误:@ types/googlemaps.只需将其添加到您的tsconfig.jsonon functions文件夹:

"files": [
    "node_modules/typescript/lib/lib.es6.d.ts"
],
"exclude": [
    "node_modules"
]
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,这解决了我在离子项目中使用Firebase的问题. (3认同)