Firebase Cloud函数:Typescript无法编译为JavaScript [英] Firebase Cloud functions: Typescript does not compile to JavaScript

查看:86
本文介绍了Firebase Cloud函数:Typescript无法编译为JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计算机上的Cloud函数可以使用Javascript,但是当我使用TypeScript尝试时,它不能编译为Javascript.它不会创建lib/index.js

Cloud function on my computer works with Javascript, but when I try it using TypeScript it does not compile to Javascript. It does not event create lib/index.js

当我运行firebase deploy时,它显示以下错误

When I run firebase deploy, it shows the error that

Error: There was an error reading functions/package.json:

firebase deploy --debug显示以下日志:

firebase deploy --debug shows the following log:

APPLEs-MacBook-Air:functions abbasi$ firebase deploy --debug
[2020-01-08T08:39:06.383Z] ----------------------------------------------------------------------
[2020-01-08T08:39:06.390Z] Command:       /usr/local/bin/node /usr/local/bin/firebase deploy --debug
[2020-01-08T08:39:06.390Z] CLI Version:   7.11.0
[2020-01-08T08:39:06.390Z] Platform:      darwin
[2020-01-08T08:39:06.391Z] Node Version:  v12.14.1
[2020-01-08T08:39:06.392Z] Time:          Wed Jan 08 2020 13:39:06 GMT+0500 (Pakistan Standard Time)
[2020-01-08T08:39:06.393Z] ----------------------------------------------------------------------
[2020-01-08T08:39:06.393Z] 
[2020-01-08T08:39:06.422Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-01-08T08:39:06.423Z] > authorizing via signed-in user
[2020-01-08T08:39:06.426Z] [iam] checking project safepay-test for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2020-01-08T08:39:06.429Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/safepay-test:testIamPermissions  
 permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get]
[2020-01-08T08:39:08.205Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Wed, 08 Jan 2020 08:39:08 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=1374, alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000, accept-ranges=none, transfer-encoding=chunked

=== Deploying to 'safepay-test'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
Running command: npm --prefix "$RESOURCE_DIR" run build
✔  functions: Finished running predeploy script.
[2020-01-08T08:39:13.911Z] > [functions] package.json contents: {
  "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.6.0",
    "firebase-functions": "^3.3.0"
  },
  "devDependencies": {
    "tslint": "^5.12.0",
    "typescript": "^3.2.2",
    "firebase-functions-test": "^0.1.6"
  },
  "private": true
}

Error: There was an error reading functions/package.json:

 functions/lib/index.js does not exist, can't deploy Cloud Functions

Having trouble? Try firebase [command] --help

我刚刚在另一位同事的Macbook上尝试过,它可以在他的系统上完美运行,但不能在我的系统上运行.

I have just tried it on another colleague's Macbook, it works on his system perfectly, but not on my system.

请帮助我.

推荐答案

我知道未安装Typescript.

I came to know that Typescript was not installed.

解决

sudo npm install -g typescript

现在它可以正常工作了

这篇关于Firebase Cloud函数:Typescript无法编译为JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆