2017-12-20 22 views
1

Firebase와 Braintree를위한 Cloud 기능을 통합 할 수 있는지 확인하려고합니다. the docs에 따라 클라우드 기능을위한 프로젝트를 만들었습니다. 프로젝트 디렉토리에서 나는 다음을 실행했습니다 : npm install braintree. 내가Braintree와 Firebase의 Cloud 기능 통합

오류 구문 분석 트리거 오류를 가지고이 테스트 기능을 배포하려고 할 때

const functions = require('firebase-functions'); 

var braintree = require("braintree"); 

var gateway = braintree.connect({ 
          environment: 
braintree.Environment.Sandbox, 
          merchantId: "useYourMerchantId", 
          publicKey: "useYourPublicKey", 
          privateKey: "useYourPrivateKey" 
          }); 


// // Create and Deploy Your First Cloud Functions 
// // https://firebase.google.com/docs/functions/write-firebase- 
functions 
// 
exports.helloWorld = functions.https.onRequest((request, response) => { 
    response.send("Hello from Firebase!"); 
//gateway.clientToken.generate({}, function (err, response) { 
    //response.send(response.clientToken); 
//}); 
}); 

: 나는 다음으로 테스트 목적 index.js을 수정 모듈 '브레인'

를 찾을 수 없습니다

저는 Firebase, Cloud Functions 및 node.js를 처음 사용하고 Braintree를 Firebase Functions 프로젝트로 가져 오는 방법에 대한 모든 정보를 제공합니다.

+0

나는 당신이 여기에있는 너무 많은 토대를 다루고 있다고 생각한다. Node.js를 처음 접한다면 Node.js에서 Braintree API를 호출하는 것으로 시작하는 것이 좋습니다. 파이어베이스를 처음 접한다면 파이어베이스와 Node.js SDK (또는 웹 컨텍스트에서 자바 스크립트에 더 익숙한 웹 SDK)와의 상호 작용을 권장합니다. 이 두 가지에 대한 경험이 있으면 클라우드 기능을 믹스에 추가하는 것이 더 나아질 것입니다. –

+0

그렇습니다. 오류의 가능한 원인에 대한 빠른 수정은 아래와 같습니다. :-) –

답변

2

Fire Base 용 Cloud Functions가 braintree 모듈을 선택하지 않은 것 같습니다. 대부분의 Node.js 환경과 마찬가지로 Cloud 기능은 package.json에서 종속성을 읽습니다. npm 모듈을 설치할 때 명령 행에 --save을 추가하여 package.json에 쓸 수도 있습니다. 따라서 :

npm install braintree --save 
2

braintree 패키지가 있습니다.

귀하의 Firebase 프로젝트에는 functions이라는 디렉토리가 있습니다. 터미널에서 $ cd {your project dir}/functions
다음으로 functions 디렉터리로 이동 한 다음 npm i braintree --save으로 이동하십시오.
도움이되기를 바랍니다.