运行firebase时,Functions文件夹在错误的路径中生成Deploy -Flutter -Firebase

问题描述

我是Firebase函数的新手,我正在尝试为Firebase设置函数,以便为我的应用中的常见活动设置通知,但是我正在遵循firebase建议的步骤(请参阅下文)功能文件夹的生成路径错误(请参见下文),firebase功能屏幕仍在询问设置。

应该在我的项目文件夹中创建Function文件夹,如何解决此问题?

1:$ npm install -g firebase-tools 2:$ firebase init 3:$ firebase deploy

C:\Users\BAQ-229\AndroidStudioProjects\reviu\Functions>firebase init

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  C:\Users\BAQ-229

Before we get started,keep in mind:

  * You are initializing in an existing Firebase project directory

? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features,then Enter to confirm your choices. Functions: Configure and deploy Cloud Functions

=== Project Setup

First,let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,but for Now we'll just set up a default project.

i  .firebaserc already has a default project,using jobly-b45bf.

=== Functions Setup

A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.

? What language would you like to use to write Cloud Functions? JavaScript
? Do you want to use ESLint to catch probable bugs and enforce style? Yes
+  Wrote functions/package.json
+  Wrote functions/.eslintrc.json
+  Wrote functions/index.js
+  Wrote functions/.gitignore
? Do you want to install dependencies with npm Now? Yes

> [email protected] postinstall C:\Users\BAQ-229\functions\node_modules\protobufjs
> node scripts/postinstall

npm notice created a lockfile as package-lock.json. You should commit this file.
added 361 packages from 266 contributors and audited 361 packages in 12.507s

32 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


i  Writing configuration info to firebase.json...
i  Writing project @R_140_4045@ion to .firebaserc...

+  Firebase initialization complete!

C:\Users\BAQ-229\AndroidStudioProjects\reviu\Functions>firebase deploy

=== deploying to 'jobly-b45bf'...

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

> functions@ lint C:\Users\BAQ-229\functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
+  functions: required API cloudbuild.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...

+  Deploy complete!

Project Console: https://console.firebase.google.com/project/jobly-b45bf/overview

解决方法

通过查看控制台的输出,您位于Functions文件夹中。在主项目文件夹(C:\ Users \ BAQ-229 \ AndroidStudioProjects \ reviu)上一级,从那里运行命令,完成后,它将创建一个名为functions的新文件夹,其中云功能的骨架将保留

更新:似乎您之前在C:\ Users \ BAQ-229上创建了一个Firestore项目,以避免在此目录内创建结构:

  1. 在您的 C:\ Users \ BAQ-229 目录或该目录下的任何其他子目录中找到并删除firebase.json文件
  2. C:\ Users \ BAQ-229 \ AndroidStudioProjects \ reviu \ 目录(我认为这是您的主项目文件夹)中再次运行firebase init命令