微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

firebase deploy get error预期的错误将被处理handle-callback-err

如何解决firebase deploy get error预期的错误将被处理handle-callback-err

firebase部署获取错误期望的错误将被处理handle-callback-err

这是我的代码;我想使用Braintree方法,当我编写index.js时,将其上传到firebase。这是错误代码

mycode

const functions = require('firebase-functions');
const braintree = require('braintree')
const express = require('express')
const cors = require('cors')

// Init app
const app = express();
app.use(cors({origin: true}));

var gateway = braintree.connect({
    environment: braintree.Environment.SandBox,merchantId:"example",//Fill information
    publicKey:"example",privateKey:"example"
});

app.get('/token',(req,response)=>{
    gateway.clientToken.generate({},(err,res)=>{
        if(res)
            response.send(JSON.stringify({error:false,token:res.clientToken}));
        else {
            response.send(JSON.stringify({error:true,errorObj:res,response:res}));
        }
    })
})

app.post('/checkout',response)=>{
    var transactionErrors;
    var amount = req.body.amount;
    var nonce = req.body.payment_method_nonce;

    gateway.transaction.sale({
        amount:amount,paymentMethodNonce:nonce,options:{
            submitForSettlement:true
        }
    },(error,result)=>{
        if(result.success || result.transaction)
        {
            response.send(JSON.stringify(result));
        }
        else {
            transactionErrors = result.errors.deepErrors();
            response.send(JSON.stringify(formatErrors(transactionErrors)))
        }
    });
});

exports.widgets = functions.https.onRequest(app);

错误代码

D:\Firebase-Braintree\functions\index.js
  18:37  error  Expected error to be handled  handle-callback-err

✖ 1 problem (1 error,0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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\A6\AppData\Roaming\npm-cache\_logs\2020-09-09T02_53_04_542Z-debug.log
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "%rESOURCE_DIR%" run lint ENOENT
    at notFoundError (C:\Users\A6\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\A6\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\A6\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\A6\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) {
  code: 'ENOENT',errno: 'ENOENT',syscall: 'spawn npm --prefix "%rESOURCE_DIR%" run lint',path: 'npm --prefix "%rESOURCE_DIR%" run lint',spawnargs: []
}

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

如何解决这个问题?

我试图删除node_modules并重新安装npm

但仍然错误

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