2017-10-18 5 views
3

을 가져올 때 'protobuf.js'를로드 할 수 없습니다 : 다음 터미널 규칙베어 노드 파일을 실행하는 경우 FireStore 문서

Firestore (4.5.2) 2017-10-18T19:16:47.719Z: INTERNAL UNHANDLED ERROR: Error: Failed to fetch file at /.../project/node_modules/protobufjs/dist/protobuf.js:5164:30 at ReadFileContext.callback (/.../p/node_modules/protobufjs/dist/protobuf.js:358:29) at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13) (node:43981) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to fetch file (node:43981) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

에서

const firebase = require("firebase"); 
const http = require('http') 

require("firebase/firestore"); 

firebase.initializeApp({ 
    apiKey: '...', 
    authDomain: '...', 
    databaseURL: '...', 
    serviceAccount: '...', 
    projectId: '...' 
}); 

var db = firebase.firestore(); 
var userRef = db.collection('...').doc('...'); 

결과를하지만 난 node_modules 폴더를 확인하고있다 . 나는 또한 그것을 다시 설치하려고 시도하고, 다른 사람들은 protobuf.js의 현재 버전에 문제가있는 것 같지 않습니다.

+0

오늘 같은 문제가 있습니다. 유사한 접근 방식을 보여주고 출력과 구성을 문서화하려면 아래에 답변을 추가하십시오. – Krispy

답변

2

유사 문제 :

const firebase = require('firebase'); 
require("firebase/firestore"); 
const config = { 
    apiKey: "-redacted-", 
    authDomain: "-redacted-", 
    databaseURL: "-redacted-", 
    projectId: "-redacted-", 
    storageBucket: "-redacted-", 
    messagingSenderId: "-redacted-" 
}; 
firebase.initializeApp(config); 
let db = firebase.firestore(); 
let ref=db.collection('example').doc('test'); 
ref.set({test:true}); 

오류 콘솔 (노드 v6.11.4)에서 :

Firestore (4.5.2) 2017-10-18T19:48:00.297Z: INTERNAL UNHANDLED ERROR: Error: Failed to fetch file 
at Error (native) 
at /Users/krispy.uccello/Development/devrel/constellation/functions/node_modules/protobufjs/dist/protobuf.js:5164:30 
at ReadFileContext.callback (/Users/krispy.uccello/Development/devrel/constellation/functions/node_modules/protobufjs/dist/protobuf.js:358:29) 
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13) 

(노드 : 71564) UnhandledPromiseRejectionWarning : 처리되지 않은 약속 거절 (거부 ID : 1) : 오류 :

service cloud.firestore { 
    match /databases/{database}/documents { 
    match /{document=**} { 
     allow read, write: if true; 
    } 
    } 
} 
,369 : 파일

데이터베이스 규칙을 가져 오지 못했습니다

업데이트 : 이 문제는 쓰기와 관련이있는 것으로 보입니다. Firestore에서 문제없이 데이터를 읽을 수있었습니다.

업데이트 # 2 : 쓰기 작업을 처리하기 위해 firebase 함수를 작성했습니다. 이 문제는 클라이언트 측에 설치되는 protobuf j의 게시 된 버전과 관련 될 수 있습니다. 파이어 폭스 엔드에서 어떤 버전이 사용되고 있는지는 확실치 않지만 작동하는 것처럼 보입니다. firebase https 트리거를 통해 호출되는 다음 함수를 참조하십시오. 작동하며 firestore 데이터베이스에 데이터가 나타납니다.

function writeWorkerProfile(id, data, res) { 
    let ref = 
    db.collection('scratch').doc('v1').collection('workers').doc(`${id}`); 
    ref.set(data) 
    .then(function() { 
    console.log("Document successfully written!"); 
    res.status(200).send({ok:true}) 
    }) 
    .catch(function(error) { 
     console.error("Error writing document: ", error); 
     res.status(500).send('Error occurred: Could not write data'); 
    }); 
} 
+0

독서에 어떤 코드를 사용 했습니까? 또한 어떻게 firebase https 트리거를 시작 했습니까? 감사! (이 뉴) – user61871

+0

이 https://gist.github.com/kuccello/d68f671ad396b8741bcdd47a7218044b https://gist.github.com/kuccello/4d367cc011aa941a456f60a01826a02f – Krispy

+0

여기에 읽기 기능입니다 다음 기 스트를 참조하십시오 HTTPS는 : // 요점 .github.com/kuccello/0ae3314bdf4d14128ee41e05cb4b5507 – Krispy

관련 문제