【问题标题】:Firebase Functions Deploy looking in wrong directory for Node_ModulesFirebase Functions Deploy 在错误的目录中查找 Node_Modules
【发布时间】:2018-09-08 12:43:15
【问题描述】:

在尝试部署我的 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.

目录结构:

我的 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
}

【问题讨论】:

    标签: firebase google-cloud-functions


    【解决方案1】:

    有同样的问题,这为我解决了Firebase-Admin package Typescript error in Cloud Functions Firestore : @types/googlemaps。 只需将其添加到您的 tsconfig.json 函数文件夹中即可:

    "files": [
        "node_modules/typescript/lib/lib.es6.d.ts"
    ],
    "exclude": [
        "node_modules"
    ]
    

    【讨论】:

    • 谢谢,这解决了我在 Ionic 项目中使用 Firebase 的问题。
    【解决方案2】:

    我的tsconfig.json 已经有了上面的filesexclude。我只需要在函数目录中运行npm install 即可解决错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-14
      • 2022-06-16
      • 1970-01-01
      • 2020-12-04
      • 2022-12-11
      • 2019-12-06
      • 2019-01-01
      • 1970-01-01
      相关资源
      最近更新 更多