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

如何解决部署错误的云功能-Firebase部署

在执行firebase deploy命令时返回错误。我尝试了一些配置选项,但没有用。

错误Firebase部署

=== Deploying to '###'...

i  deploying functions
Running command: npm --prefix "%RESOURCE_DIR%" run lint

> functions@ lint C:\usCloud\functions
> tslint --project tsconfig.json


WARNING: C:/usCloud/functions/src/index.ts:13:10 - bodyParser is deprecated.
WARNING: C:/usCloud/functions/src/index.ts:14:10 - bodyParser is deprecated.

Running command: npm --prefix "%RESOURCE_DIR%" run build

> functions@ build C:\usCloud\functions
> tsc

node_modules/@google-cloud/firestore/types/firestore.d.ts:23:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentData,UpdateData,Firestore,GeoPoint,Transaction,WriteBatch,WriteResult,DocumentReference,DocumentSnapshot,QueryDocumentSnapshot,OrderByDirection,WhereFilterOp,Query,QuerySnapshot,DocumentChangeType,CollectionReference,FieldValue,FieldPath,Timestamp,v1beta1,v1,OK,CANCELLED,UNKNOWN,INVALID_ARGUMENT,DEADLINE_EXCEEDED,NOT_FOUND,ALREADY_EXISTS,PERMISSION_DENIED,RESOURCE_EXHAUSTED,FAILED_PRECONDITION,ABORTED,OUT_OF_RANGE,UNIMPLEMENTED,INTERNAL,UNAVAILABLE,DATA_LOSS,UNAUTHENTICATED,FirebaseFirestore

23 declare namespace FirebaseFirestore {
   ~~~~~~~

  node_modules/firebase-functions-helper/node_modules/@google-cloud/firestore/types/firestore.d.ts:25:1
    25 declare namespace FirebaseFirestore {
       ~~~~~~~
    Conflicts are in this file.

node_modules/firebase-functions-helper/node_modules/@google-cloud/firestore/types/firestore.d.ts:25:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentData,FirebaseFirestore

25 declare namespace FirebaseFirestore {
   ~~~~~~~

  node_modules/@google-cloud/firestore/types/firestore.d.ts:23:1
    23 declare namespace FirebaseFirestore {
       ~~~~~~~
    Conflicts are in this file.

node_modules/firebase-functions-helper/node_modules/@google-cloud/firestore/types/firestore.d.ts:168:5 - error TS2374: Duplicate string index signature.

168     [key: string]: any; // Accept other properties,such as GRPC settings.
        ~~~~~~~~~~~~~~~~~~~


Found 3 errors.

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!     C:\Users\##\AppData\Roaming\npm-cache\_logs\2020-08-26T16_49_58_562Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code2

我的index.ts

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import * as firebaseHelper from 'firebase-functions-helper/dist';
import * as express from 'express';
import * as bodyParser from 'body-parser';

admin.initializeApp(functions.config().firebase);
const db = admin.firestore;

const app = express();
const main = express();

main.use(bodyParser.json());
main.use(bodyParser.urlencoded({extended: false}));
main.use('/api/v1',app);

const trackerCollection = 'tracker';
export const webApi = functions.https.onRequest(main);

app.patch('/tracker/:tid',async(req,res) => {
    try {
        await firebaseHelper.firestore.updateDocument(db,trackerCollection,req.params.tid,req.body);
        res.status(200).send('Update Success');
    } catch (error) {
        res.status(204).send('Patch Error');
    }
})

tsconfig.json-原始状态,不变。

{
  "compilerOptions": {
    "module": "commonjs","noImplicitReturns": true,"noUnusedLocals": true,"outDir": "lib","sourceMap": true,"strict": true,"target": "es2017"
  },"compileOnSave": true,"include": [
    "src"
  ],}

package.json-原始状态,不变。

{
  "name": "functions","scripts": {
    "lint": "tslint --project tsconfig.json","build": "tsc","serve": "npm run build && firebase emulators:start --only functions","shell": "npm run build && firebase functions:shell","start": "npm run shell","deploy": "firebase deploy --only functions","logs": "firebase functions:log"
  },"engines": {
    "node": "10"
  },"main": "lib/index.js","dependencies": {
    "body-parser": "^1.19.0","express": "^4.17.1","firebase-admin": "^8.10.0","firebase-functions": "^3.6.1","firebase-functions-helper": "^0.8.0"
  },"devDependencies": {
    "firebase-functions-test": "^0.2.0","tslint": "^5.12.0","typescript": "^3.9.7"
  },"private": true
}

我更改了一些打字稿设置,但是没有用。我将所有内容恢复为原始状态。

解决方法

显然,发出命令firebase init解决了这种情况。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?