找不到模块“firebase-functions”

时间:2018-05-04 08:47:57

标签: firebase google-cloud-functions

我使用firebase-functions导入并下载了firebase-adminnpm i <package>,但它给了我一个lint错误,如:cannot find module "firebase-functions"。我也重新启动了 vscode ,但问题仍然存在..

screenhost 1 screenhost 2

webpack tsconfig 会出现问题吗?

package.json 中的一些重要软件包:

{
    "dependencies": {
    "@angular/animations": "^5.2.3",
    "@angular/cdk": "^5.1.1",
    "@angular/common": "^5.2.2",
    "@angular/compiler": "^5.2.2",
    "@angular/core": "^5.2.2",
    "@angular/forms": "^5.2.2",
    "@angular/http": "^5.2.2",
    "@angular/material": "^5.0.2",
    "@angular/material-moment-adapter": "^5.2.3",
    "@angular/platform-browser": "^5.2.2",
    "@angular/platform-browser-dynamic": "^5.2.2",
    "@angular/platform-server": "^5.2.3",
    "@angular/router": "~5.2.2",
    "core-js": "^2.5.3",
    "express": "^4.16.2",
    "firebase": "^4.9.1",
    "firebase-admin": "~5.8.1",
    "firebase-functions": "^0.8.1",
    "zone.js": "0.8.18"
  },
  "private": true,
  "devDependencies": {
    "@angular/cli": "^1.6.7",
    "@angular/compiler-cli": "^5.2.2",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-universal-express-firebase": "0.0.4",
    "babel-preset-es2015": "^6.24.1",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "npm-run-all": "^4.1.2",
    "protractor": "~5.1.2",
    "ts-loader": "^3.4.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "^2.4.2",
    "webpack": "^3.8.1",
    "webpack-node-externals": "^1.6.0"
  }

}

4 个答案:

答案 0 :(得分:3)

您可以尝试以下命令:

firebase use --add
firebase init functions

获取您的项目。有时,这是一个权限问题。您可以尝试在计算机上创建一个新帐户并执行相同的命令,这几乎总是可行的。

答案 1 :(得分:0)

我通过这些步骤解决了这个问题。我真的不知道确切的解决方案是否已删除并再次初始化firebase功能。另外我认为问题不仅仅是firebase-functions或firebase-admin。它可能缺少node_modules包。

  1. 删除函数中的node_modules
  2. firebase init functions。更新tsconfig和package.json并安装依赖项。
  3. restart vscode

答案 2 :(得分:0)

@Shaybakov的回答是解决我的问题的方法。

我最近在本地计算机上切换了项目位置。这意味着Firebase库没有导入到本地目录中,我要么必须重新配置整个firebase CLl,要么仅使用@Shaybakov声明的命令手动更新本地目录中的firebase库。

npm install firebase-functions
npm install firebase-admin

答案 3 :(得分:-1)

npm install firebase-functions
npm install firebase-admin