标签: firebase-cli

firebase-tools 无法通过 macOS 上的终端安装加载

尝试为 CLI 安装 firebase-tool。获得失败。

在 macOS 上运行

我已经看到如下建议......

安装 firebase-tools 时遇到麻烦

我试过 $ sudo npm install -g firebase-tools

使用“sudo”可以解决尝试访问目录的错误问题。但仍然崩溃

令人不安的一点似乎是这个

 node-pre-gyp ERR! Tried to download(undefined):       https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.4.1/node-v57-darwin-x64.tar.gz 
Run Code Online (Sandbox Code Playgroud)

我可以将上面的 URL 放在浏览器中,它会下载 tar。

即使我使用“sudo”,我也有访问问题

 gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/build'
Run Code Online (Sandbox Code Playgroud)

试图了解如何克服安装 firebase-tools 的错误,还有一些建议说通过 nvm 安装节点。在 nvm 上找到教程,任何人都知道此安装对我机器上已有的项目有何影响。例如混淆找到正确的node.js,或者需要重新安装我使用当前节点安装已经安装的所有东西?

完整的错误消息是...

  sudo npm install -g firebase-tools
  Password:
  npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
  /usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-     tools/bin/firebase

  > grpc@1.4.1 install /usr/local/lib/node_modules/firebase-   tools/node_modules/grpc
  > node-pre-gyp install --fallback-to-build --library=static_library …
Run Code Online (Sandbox Code Playgroud)

macos node.js firebase angular firebase-cli

5
推荐指数
2
解决办法
3506
查看次数

Firebase 托管仅部署到子目录

我想知道“Firebase deploy”可以只更新根目录下的子目录吗?

我的结构

/public (index.html,other 100+ files)
/public/data (require.json) ::only 1 file
Run Code Online (Sandbox Code Playgroud)

问题是我大约每小时只需要更新(部署)1 个文件“/public/data/require.json”。但是在部署时,公共文件夹中的所有数据(和文件夹)都会更新并且消耗太多成本。

无论如何只更新 webroot 中的 1 个特定文件夹或文件。谢谢你。

firebase firebase-hosting firebase-cli

5
推荐指数
1
解决办法
1637
查看次数

从Firestore中删除所有文档和集合

我正在尝试清除一个Firestore数据库,该数据库中包含大量文档和子集合以供测试.Firebase CLI(firebase-tools@3.18.4)建议从Cloud Firestore删除数据的可能性如下:

用法: firestore:删除[options] [path]

选项:

-r, --recursive    Recursive. Delete all documents and subcollections. Any action which would result in the deletion of child documents will fail if this argument is not passed. May not be passed along with --shallow.
--shallow          Shallow. Delete only parent documents and ignore documents in subcollections. Any action which would orphan documents will fail if this argument is not passed. May not be passed along with -r.
--all-collections  Delete all. Deletes the entire Firestore …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-firestore firebase-cli

5
推荐指数
1
解决办法
751
查看次数

Firebase功能部署问题:%RESOURCE_DIR%中找不到package.json

我遇到部署Firebase云功能的问题.

重现步骤

  • firebase init
  • 仅选择功能
  • 选择Firebase项目
  • 选择Javascript
  • 使用ESLint
  • 现在用npm安装依赖项
  • 运行firebase部署

预期结果

期望使用firebase-tools来部署云功能.

实际结果

收到以下错误消息:

? firebase deploy

=== Deploying to '<projects>'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! path ...path\firebaseFunction\%RESOURCE_DIR%\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '...path\firebaseFunction\%RESOURCE_DIR%\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete …
Run Code Online (Sandbox Code Playgroud)

node.js npm firebase google-cloud-functions firebase-cli

5
推荐指数
2
解决办法
3234
查看次数

Firebase Cloud Function 部署 tslint 错误

我使用 CLI 启动了一个新的 Firebase 项目。我只使用 Cloud 功能并想部署一些功能,但我收到此错误

functions@ lint: `tslint --project tsconfig.json`
Run Code Online (Sandbox Code Playgroud)

我已经更改了以下几行:

  "npm --prefix \"$RESOURCE_DIR\" run lint",
  "npm --prefix \"$RESOURCE_DIR\" run build"
Run Code Online (Sandbox Code Playgroud)

  "npm --prefix \"%RESOURCE_DIR%\" run lint",
  "npm --prefix \"%RESOURCE_DIR%\" run build"
Run Code Online (Sandbox Code Playgroud)

因为他们也抛出了错误。

我需要改变什么?

编辑:

我使用 cli 创建了一个新的 Firebase 项目(在名为 Firebase 的文件夹中),并且仅使用 Cloud 函数。然后我将所有 .ts 文件复制到 src 文件夹中并添加了我的依赖项。

 "firebase-admin": "~5.12.1",
 "firebase-functions": "^1.0.3",
 "@types/async": "^2.0.48",
 "@types/camelcase": "^4.1.0",
 "@types/glob": "^5.0.35",
 "@types/request": "^2.47.0",
 "@types/xml2js": "^0.4.2",
 "async": "^2.6.0",
 "camelcase": "^4.1.0",
 "glob": "^7.1.2",
 "install": "0.10.4",
 "npm": "5.6.0",
 "request": "^2.85.0",
 "xml2js": "^0.4.19" 
Run Code Online (Sandbox Code Playgroud)

然后我运行 firebase …

firebase google-cloud-functions firebase-cli

5
推荐指数
2
解决办法
6969
查看次数

Firebase 云函数 Firestore 触发 onWrite 在本地测试时未按预期运行

我正在使用 Firebase Functions Shell 在 Node 中本地测试 Firestore 触发的 Firebase Cloud Function。

当使用 onWrite 触发器并通过updateMonth({foo:'new'})从函数外壳调用传递新文档时,我无法获得对新文档的引用。

exports.updateMonth = functions.firestore
.document('users/{userId}').onWrite((change, context) => {
    const document = change.after.exists ? change.after.data() : null;
    console.log("change.after.exists", change.after.exists)
    console.log("change.before.exists", change.before.exists)
    const oldDocument = change.before.data();
    console.log("Old:",oldDocument)
    return true
})
Run Code Online (Sandbox Code Playgroud)

当同时使用 before 和 after 来模拟文档更新时,updateMonth({before:{foo:'old'},after:{foo:'new'}})它会按预期工作。但是,当使用 just 调用时updateMonth({foo:'new'}),前后文档似乎都不存在:

i  functions: Preparing to emulate functions.
Warning: You're using Node.js v8.4.0 but Google Cloud Functions only supports v6.11.5.
+  functions: hi
+  functions: helloWorld
+ …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions google-cloud-firestore firebase-cli

5
推荐指数
1
解决办法
4307
查看次数

在刷新之前部署Firebase应用程序会中断

每当我部署我的Firebase应用程序进行托管时,这是一个打包的Create-React-App,那么当浏览器第一次加载它时,控制台会显示:

main.27e9b1c2.js:1 Uncaught SyntaxError:意外的令牌<

F5刷新修复它.然后该网站正常运行,直到我下次部署.

我正在使用firebase托管和firebase工具进行部署.mainjs上的数字是当前版本.

firebase firebase-hosting create-react-app firebase-cli

5
推荐指数
1
解决办法
168
查看次数

Firebase部署无法找到firebase.json

因此,我是编程新手,仍然在学习一些东西(我使用Windows btw)

我尝试制作一个应用程序,将其连接到Firebase。设置完所有内容后,再设置CLI

好消息:我成功设置了从节点到nvm的所有内容,直到在CLI中成功启动登录为止。

坏消息:在成功登录CLI后,我正在尝试键入cmd

firebase deploy --only功能

并出现此错误

错误:不在Firebase应用程序目录中(无法找到firebase.json)

我已经在网上搜索了解决方案,但一无所获

有人可以告诉我我想念什么吗?谢谢。

firebase google-cloud-functions firebase-cli

5
推荐指数
2
解决办法
3436
查看次数

如何将 Firebase 存储规则部署到特定存储桶?

我想知道 Firebase 中的存储规则部署是如何工作的。

在 Firebase 存储中,我有 2 个存储桶app.appspot.comapp-mybucket. 在我的本地机器上,我有一个storage.rules看起来像这样的文件:

service firebase.storage {
  match /b/app.appspot.com/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
  match /b/app-mybucket/o {
    match /{userId}/{allPaths=**} {
      allow read, write: if request.auth.uid == userId;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

当我将firebase deploy --only storage这些规则发送到默认app.appshpot.com存储桶时,似乎没有任何内容发送到app-mybucket. 我想知道一种可以将规则部署到所有存储桶的方法。

firebase firebase-security firebase-storage firebase-cli

5
推荐指数
2
解决办法
1153
查看次数

Firebase-权限不足,即使我是项目所有者

我正在尝试通过调用以下命令使用Firebase CLI 导出Firebase用户帐户firebase auth:export save_file.json --format=json --project=MyProjectName

这将返回以下错误消息:

Error: Authorization failed. This account is missing the following required permissions on project MyProject:

  firebase.projects.get
  firebaseauth.users.get
Run Code Online (Sandbox Code Playgroud)

我的帐户具有所有者级别的权限,根据GCloud IAM设置页面,该权限具有“对所有资源的完全访问权限”。

所有者帐户怎么会缺少必需的权限?我如何克服此错误来执行导出?

我已确认我已登录CLI的正确帐户。当我执行firebase login它时,返回的Already logged in as ****@gmail.com是与我拥有所有者级别权限的帐户相同的帐户(以及创建项目的帐户)。

firebase firebase-authentication firebase-cli

5
推荐指数
1
解决办法
399
查看次数