2017-10-18 6 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:未処理の約束拒否(拒絶番号:1)エラー:

service cloud.firestore { 
    match /databases/{database}/documents { 
    match /{document=**} { 
     allow read, write: if true; 
    } 
    } 
} 
:ファイル

Databaseルールの取得に失敗しました

更新: この問題は書き込みにのみ関連しているようです。 Firestoreから問題なくデータを読み取ることができました。

更新#2: 書き込み操作を処理するためのfirebase関数を作成しました。この問題は、クライアントサイドにインストールされている公開されたprotobuf jのバージョンに関連する可能性があります。 Firebaseエンドでどのバージョンが使用されているのかはっきりしていませんが、動作するようです。 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トリガを開始しましたか?ありがとう! ます。https://要旨(これまで新) – user61871

+0

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

+0

が読み取り機能がある、以下の要旨を参照してください。 .github.com/kuccello/0ae3314bdf4d14128ee41e05cb4b5507 – Krispy

関連する問題