标签: firebase-cli

错误:函数predoploy错误:命令以非零退出代码终止4294963238

我正在尝试使用cmd提示部署Firebase angular js Web应用程序功能:

firebase deploy --only functions
Run Code Online (Sandbox Code Playgroud)

但是我不断得到错误代码:

C:\Users\deji\Desktop\TNF>firebase deploy --only functions

=== Deploying to 'fantasyapp-a5717'...

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

> functions@ lint C:\Users\deji\Desktop\TNF\functions
> eslint .


C:\Users\deji\Desktop\TNF\functions\index.js
  17:5   error    Expected catch() or return                  promise/catch-or-return
  17:54  error    Each then() should return a value or throw  promise/always-return
  17:54  warning  Unexpected function expression              prefer-arrow-callback
  19:9   error    Expected catch() or return                  promise/catch-or-return
  19:9   warning  Avoid nesting promises                      promise/no-nesting
  21:9   warning  Unexpected function expression              prefer-arrow-callback
  21:9   error …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
1308
查看次数

如何解决TypeError:functions.https.onCall不是函数?

我有一个我今年早些时候创建的Firebase项目.它使用云功能在实时数据库上运行某些操作.

昨天,我了解了可调用云功能,所以我决定在我的应用程序中尝试它,看看我是否应该更新我现有的功能.我为测试目的创建了一个简单的云函数:

exports.testCall = functions.https.onCall((data, context) =>{
    console.log(context.auth.uid);
    return {response:"This means success"};
});
Run Code Online (Sandbox Code Playgroud)

但是当我尝试部署此函数时,我收到错误:

错误:解析函数触发器时发生错误.

TypeError:functions.https.onCall不是 Object 的函数.(/tmp/fbfn_7614ijhDwX0NY98S/index.js:114:36)在Module.load的Object.Module._extensions..js(module.js:660:10)的Module._compile(module.js:649:30)处( module.js:561:32)在tryModuleLoad(module.js:501:12)的Function.Module._load(module.js:493:3)的Module.require(module.js:593:17)at require( internal/module.js:11:18)atus的/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11.(/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:32:3)

我知道Callable Cloud Functions已经在最新的Firebase SDK中引入,所以我尝试使用以下方法更新它:

sudo npm install -g firebase-tools
Run Code Online (Sandbox Code Playgroud)

但我还不能部署我的云功能.我也尝试过部分部署,如Firebase文档中所示,但它没有用.文档中有没有我遗漏的东西?

firebase firebase-tools google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
1238
查看次数

“部署到多个环境”的 Firebase 函数版本

正如这里所建议的:“ https://firebase.googleblog.com/2016/07/deploy-to-multiple-environments-with.html ”,一个应该使用多个项目(最好将名称区分为 dev、staging、production 等) 以便能够在 Firebase 托管上拥有类似的测试环境。

但同样,本文档在 Firebase 托管的上下文中讨论了这种方法。如果我不想在测试“开发”版本之前更新我已经上线的“生产”功能,或者是否有可以遵循的替代方法?

我认为我不能简单地添加另一个 Firebase 函数,因为代码仍会在“生产”版本和“开发”版本之间共享,这可能会导致“生产”版本出现问题。

firebase google-cloud-platform firebase-hosting google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
435
查看次数

如何使用Firebase重置默认项目托管?

我一直在使用Firebase测试应用程序。我将某个项目设置为默认项目。现在,我想部署一个不同的项目,但不了解如何默认删除以前的项目。(我几乎没有使用终端的经验)。

terminal firebase firebase-hosting firebase-cli

2
推荐指数
1
解决办法
2165
查看次数

Firebase 仅部署功能流程

如果我有两个 Firebase 函数 (fire1fire2) 共享一个辅助函数 ( doSum),那么部署会firebase deploy --only functions:fire1改变fire2?

firebase google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
521
查看次数

Firebase 部署不更新内容

早些时候我使用 Firebase 在 reactJs 上部署了我的项目,最近我对它进行了更改并使用“firebase deploy”再次部署它,但结果 URL 仍然显示以前的内容而不是更新的内容!我能做什么?有什么建议?

硬重新加载/使用隐身窗口/在firebase/更新的Js文件上也更改了我的项目

firebase firebase-hosting firebase-cli

2
推荐指数
1
解决办法
2412
查看次数

在 firebase 中动态导出函数

我在云功能中遇到冷启动时间的典型(根据许多帖子)问题。似乎承诺的解决方案建议仅导入/导出实际执行的函数,如下所示:

https://github.com/firebase/functions-samples/issues/170#issuecomment-323375462

if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'sendFollowerNotification') {
  exports.sendFollowerNotification = require('./sendFollowerNotification');
}
Run Code Online (Sandbox Code Playgroud)

这是一个 Javascript 示例,但我使用的是打字稿。我尝试了许多变体,虽然进行了一些构建,但最终我总是坚持我的函数没有被导出,并且部署警告我我将删除现有函数。

这是众多尝试之一:

if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'generateInviteURL') {
  import ('./invite_functions').then ((mod) => { console.log ("mod follows" ); console.log (mod);  exports.generateInviteURL = functions.https.onRequest( mod.generateInviteURL ); } )
  .catch ((err) => {console.log ("Trying to import/export generateInviteURL ", err);}) ;
}
Run Code Online (Sandbox Code Playgroud)

提到,在部署时会发生什么是我收到有关该函数被删除的警告。

我能够通过以下方式“避免”该消息:

console.log ("Function name: ", process.env.FUNCTION_NAME);

function dummy_generateInviteURL (req, res) { ; }
exports.generateInviteURL = functions.https.onRequest( dummy_generateInviteURL );

if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'generateInviteURL') { …
Run Code Online (Sandbox Code Playgroud)

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

2
推荐指数
1
解决办法
1808
查看次数

如何使用Firebase云功能pubsub.schedule?

如今,Firebase的Cloud Functions的新功能正在按计划运行功能。因此,我尝试测试示例代码。

index.js文件

exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
  console.log(‘This will be run every 5 minutes!’);
});
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试部署它时,出现以下错误消息:


Error: Error occurred while parsing your function triggers.

TypeError: functions.pubsub.schedule is not a function
Run Code Online (Sandbox Code Playgroud)

我的Firebase工具版本为6.7(今天更新)

解决办法是什么?

我在这里检查了示例git代码(https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js

但这也会导致相同的错误:

functions.pubsub.schedule不是函数

谁能帮助我解决这个问题?

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
   console.log('This will be run every 5 minutes!');
});
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions firebase-cli

2
推荐指数
1
解决办法
1839
查看次数

集合组查询中 firestore 单个字段索引的 JSON 格式是什么?

我们现在可以从集合组中检索文档,这很棒。为此,我需要通过 Firebase 控制台上的错误消息创建索引。如何将此新索引添加到 firestore.indexes.json 文件?

文档示例:

let museums = db.collectionGroup('landmarks').where('type', '==', 'museum');
museums.get().then(function(querySnapshot) {
  querySnapshot.forEach(function(doc) {
    console.log(doc.id, ' => ', doc.data());
  });
});
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-firestore firebase-cli

2
推荐指数
1
解决办法
834
查看次数

Firebase CLI 始终显示错误:项目 ID 无效:\

每次我使用 firebase 命令时都会发生此错误:

...\WEBRTCTest\FirebaseRTC> firebase use --add

Error: Invalid project id: \.
Run Code Online (Sandbox Code Playgroud)
\WEBRTCTest\FirebaseRTC> firebase use --clear

Error: Invalid project id: \.
Run Code Online (Sandbox Code Playgroud)

我不小心运行命令后发生错误:

firebase use \
Run Code Online (Sandbox Code Playgroud)

在此之前,一切正常。

我尝试使用 npm 重新安装 firebase-tools,并从 github 重新克隆示例项目。还尝试使用注销firebase logout但它给了我同样的错误:

\WEBRTCTest\FirebaseRTC> firebase use --clear

Error: Invalid project id: \.
Run Code Online (Sandbox Code Playgroud)

我很感激任何想法,因为我现在被困住了。

firebase firebase-cli

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