标签: google-cloud-functions

在npm上使用firebase部署时出错--prefix $ RESOURCE_DIR运行lint

我有一个全新安装的firebase工具(按照本教程),我正在尝试上传我的第一个firebase功能.我在hello-world示例中遇到了这个问题,它们在运行firebase init时初始化(在init期间唯一设置函数CLI功能)

如果我取代$RESOURCE_DIRfirebase.json我的文件夹功能,它的工作原理,但当然这是不好的做法,我想找到一个妥善$RESOURCE_DIR的作品更换.

PS D:\workspace\firebase-functions> firebase deploy

    === Deploying to 'newagent-5221d'...

i  deploying functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path D:\workspace\firebase-functions\$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 'D:\workspace\firebase-functions\$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 log of …
Run Code Online (Sandbox Code Playgroud)

npm firebase google-cloud-functions

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

如何为Firebase的Cloud Functions设置本地环境变量

我正在使用http云函数来侦听请求,然后返回一条简单的消息.

我正在使用以下方式在本地开发云功能:

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

我使用设置了一些自定义环境变量

firebase functions:config:set
Run Code Online (Sandbox Code Playgroud)

在部署项目时,使用以下代码访问自定义配置变量可以正常工作

 functions.config()
Run Code Online (Sandbox Code Playgroud)

但在本地开发时它不起作用.当命中触发该函数时:http:// localhost:5002/my-project-name/us-central1/functionName我无法访问自定义配置变量.当在本地使用functions.config()时,我可以看到默认配置,而不是我的自定义配置变量

在本地工作时是否有替代解决方案或环境变量的最佳实践?

firebase google-cloud-functions

50
推荐指数
3
解决办法
1万
查看次数

Firebase的云功能 - getaddrinfo ENOTFOUND

尝试使用PayPal-node-SDK向Paypal的API发出请求

exports.requestPayment = functions.https.onRequest((req, res) => {
    return new Promise(function (fullfilled, rejected) {
        paypal.payment.create(create_payment_json, {}, function (error, payment) {
            if (error) {
                rejected(error);
            } else {
                console.log("Create Payment Response");
                console.log(payment);
                res.status(200).send(JSON.stringify({
                    paymentID: payment.id
                })).end();
                fullfilled(payment);
            }
        });
     });
});
Run Code Online (Sandbox Code Playgroud)

但我经常收到一个错误:

Error: getaddrinfo ENOTFOUND api.sandbox.paypal.com api.sandbox.paypal.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
Run Code Online (Sandbox Code Playgroud)

我试过的事情:

  1. 仍然是向完全不同的主机提出请求 ENOTFOUND
  2. 用包装请求 cors(req,res, ()=>{...})
  3. 预先https://主持人

问题是什么?

dns paypal node.js firebase google-cloud-functions

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

HTTP错误:401为android项目设置firebase云功能

我正在尝试设置firebase函数,但运行firebase init后出错.

错误:HTTP错误:401,请求具有无效的身份验证凭据.预期的OAuth 2访问令牌,登录cookie或其他有效的身份验证凭据.请参阅https://developers.google.com/identity/sign-in/web/devconsole-project.

在此输入图像描述

firebase google-cloud-functions firebase-cli

44
推荐指数
3
解决办法
8218
查看次数

何时选择App Engine over Cloud Functions?

对不起,如果这是一个天真的问题,但我看了谷歌的工作人员的一堆谈话,仍然不明白为什么我会使用AE而不是CF?

如果我理解正确的话,这两种服务的整体概念就是构建"微服务架构".

  • CF和AE都是无国籍的
  • 两者都假设在有限的时间内执行
  • 两者都可以与dbs和其他gcp apis交互.

虽然,AE必须包装到自己的服务器中.基本上它在与CF相同的功能之上利用了许多复杂性.那么,我何时应该使用它而不是CF?

google-app-engine google-cloud-platform google-cloud-functions serverless

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

Google Firebase错误(函数返回未定义,预期的Promise或值)

我正在使用Firebase开发Server.

我在Youtube上复制了Google Developer's Video .

它运行良好,但在日志中有一个错误:

函数返回undefined,预期Promise或value

它说函数返回了undefined,但是我function返回一个promise`set``

我怎么解决这个问题?

function sanitize(s) {
    var sanitizedText = s;
    console.log('sanitize params: ', sanitizedText);
    sanitizedText = sanitizedText.replace(/\bstupid\b/ig, "wonderful");
    return sanitizedText;
}
exports.sanitizePost = functions.database
    .ref('/posts/{pushId}')
    .onWrite(event => {
        const post = event.data.val();
        if (post.sanitized) return;

        console.log('Sanitizing new post', event.params.pushId);
        console.log(post);
        post.sanitized = true;
        post.title = sanitize(post.title);
        post.body = sanitize(post.body);
        return event.data.ref.set(post); 
    })
Run Code Online (Sandbox Code Playgroud)

我是Firebase,Nodejs的初学者.

javascript node.js firebase firebase-realtime-database google-cloud-functions

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

400 未找到项目的计费帐户。必须启用计费才能激活服务

我在这里通过本教程使用 firebase 创建 API 。

在我运行时:

firebase deploy
Run Code Online (Sandbox Code Playgroud)

我在命令行上收到此错误:

HTTP 错误:400,未找到项目“381106441303”的结算帐户。必须为激活服务“cloudbuild.googleapis.com,containerregistry.googleapis.com”启用计费才能继续。

请告诉我如何解决这个问题!

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

41
推荐指数
4
解决办法
2万
查看次数

firebase deploy --only函数覆盖现有函数

运行firebase deploy --only functions在创建新函数之前删除现有函数.是否可以将此行为修改为create if not exist, update if exists, no actions if functions not being deployed

function firebase firebase-tools google-cloud-functions

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

使用firebase云功能向非谷歌服务器发送POST请求

我想知道是否可以使用firebase云功能向非谷歌服务器发送一个帖子请求(我可以找到我需要在火焰计划上与非谷歌服务器进行交互)

基本上我想在每次将值添加到数据库时POST到运行在arduino上的外部服务器.

我查看了文档并找到了云函数响应HTTP post请求(HTTP云函数)的示例,但似乎无法找到任何发布到外部服务器的示例.这可能吗?

javascript firebase google-cloud-functions

39
推荐指数
2
解决办法
3万
查看次数

无法部署 Firebase 功能(无法获取运行服务未定义)

无法部署 Firebase 功能。我有两个项目别名,它对于第一个项目(dev)工作正常,但对于第二个项目(prod)则不然。
每当我写作时,firebase deploy --only functions我都会收到以下消息

i deploying functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
+  functions: required API cloudbuild.googleapis.com is enabled
+  artifactregistry: required API artifactregistry.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing codebase default for deployment
!  functions: package.json indicates an outdated version of firebase-functions. Please upgrade 
using npm install --save firebase-functions@latest …
Run Code Online (Sandbox Code Playgroud)

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

39
推荐指数
3
解决办法
7254
查看次数