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

Firebase云功能部署错误-错误TS6133

  •  0
  • Alexa289  · 技术社区  · 5 年前

    我只是在尝试firebase云功能。index.ts只是一个你好的世界。但是我在部署firebase云功能时出错了。

    我只是从这里开始学习视频教程: https://www.youtube.com/watch?v=DYfP-UIKxH0

    i  deploying functions
    Running command: npm --prefix "$RESOURCE_DIR" run lint
    
    > functions@ lint /Users/muchammadagunglaksana/Documents/Latihan/cloud_function/doug_youtube/functions
    > tslint --project tsconfig.json
    
    Running command: npm --prefix "$RESOURCE_DIR" run build
    
    > functions@ build /Users/muchammadagunglaksana/Documents/Latihan/cloud_function/doug_youtube/functions
    > tsc
    
    src/index.ts:1:1 - error TS6133: 'functions' is declared but its value is never read.
    
    1 import * as functions from 'firebase-functions';
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    
    Found 1 error.
    
    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.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/muchammadagunglaksana/.npm/_logs/2019-09-09T03_21_14_265Z-debug.log
    
    Error: functions predeploy error: Command terminated with non-zero exit code2
    Muchammads-MacBook-Air:doug_youtube muchammadagunglaksana$ 
    

    这是索引。

    import * as functions from 'firebase-functions';
    
    // Start writing Firebase Functions
    // https://firebase.google.com/docs/functions/typescript
    
    export const helloWorld = functions.https.onRequest((request, response) => {
     response.send("Hello from Firebase!");
    });
    

    这是我的package.json

    {
      "name": "functions",
      "scripts": {
        "lint": "tslint --project tsconfig.json",
        "build": "tsc",
        "serve": "npm run build && firebase serve --only functions",
        "shell": "npm run build && firebase functions:shell",
        "start": "npm run shell",
        "deploy": "firebase deploy --only functions",
        "logs": "firebase functions:log"
      },
      "engines": {
        "node": "8"
      },
      "main": "lib/index.js",
      "dependencies": {
        "firebase-admin": "^8.0.0",
        "firebase-functions": "^3.1.0"
      },
      "devDependencies": {
        "tslint": "^5.12.0",
        "typescript": "^3.2.2"
      },
      "private": true
    }
    

    我该怎么办?

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

    我怀疑您在部署之前没有保存源文件。在磁盘上,该函数可能仍被注释掉,这将导致 functions 不用了。