获得';FirebaseError:编译规则时出错';firebase emulator中非常简单的规则定义 总结

获得';FirebaseError:编译规则时出错';firebase emulator中非常简单的规则定义 总结,firebase,google-cloud-firestore,firebase-security,Firebase,Google Cloud Firestore,Firebase Security,firebase emulator试图解析最简单的firestore规则时出错 考虑到它如此简单,我不禁想这可能是某种版本控制问题?但不是很确定。我已尝试更新firebase工具。我在stackoverflow和其他地方找不到类似的错误 希望有人对此有一些想法 消防队规则 试图运行“npm测试”/“mocha测试”时,模拟器解析firestore.rules时出错(请参阅下面的测试) 正在运行单元测试 它在“等待火力基地…”线路上失败 我所期待的 上面的firestore.rules将在没有任何

firebase emulator试图解析最简单的firestore规则时出错

考虑到它如此简单,我不禁想这可能是某种版本控制问题?但不是很确定。我已尝试更新firebase工具。我在stackoverflow和其他地方找不到类似的错误

希望有人对此有一些想法

消防队规则 试图运行“npm测试”/“mocha测试”时,模拟器解析firestore.rules时出错(请参阅下面的测试) 正在运行单元测试 它在“等待火力基地…”线路上失败

我所期待的 上面的firestore.rules将在没有任何问题的情况下进行解析,以便运行mocha测试

版本 firebase 9.5.0找到了答案

我需要阅读消防商店的规则

他失踪了

  • 常数fs=要求('fs');在顶部,以及
  • firebase.loadFirestoreRules({ projectd:MY_PROJECT_ID, 规则:fs.readFileSync('../firestore.rules','utf8') }) …在我尝试调用任何规则之前
  • 很确定这不在谷歌关于测试规则的YouTube视频中,但在页面下方的2/3左右的文档中

    service cloud.firestore {
      match /databases/{database}/documents {
        match /users/{userID} {
          allow read, write: if request.auth != null;
        }
      }
    }
    
    L5:11 Missing 'match' keyword before path.
    L6:7 Unexpected 'allow'.
    L6:7 mismatched input 'allow' expecting {'{', '/', PATH_SEGMENT}
    L8:11 Missing 'match' keyword before path.
    L9:7 Unexpected 'allow'.
    L9:7 mismatched input 'allow' expecting {'{', '/', PATH_SEGMENT}
    L9:28 Missing 'match' keyword before path.
    L9:38 Forward slash '/' found where identifier or binding expected.
    L9:39 mismatched input '$' expecting {'{', '/', PATH_SEGMENT}
    L9:50 Missing 'match' keyword before path.
    L9:66 Forward slash '/' found where identifier or binding expected.
    L9:67 Unexpected '$'.
    L9:68 Unexpected '{'.
    L9:69 mismatched input 'request' expecting {'{', '/', PATH_SEGMENT}
    L9:86 Unexpected ')'.
    L15:1 Unexpected '}'.
          at new FirestoreError (node_modules\@firebase\firestore\dist\index.node.cjs.js:1205:28)
          at fromRpcStatus (node_modules\@firebase\firestore\dist\index.node.cjs.js:5240:12)
          at fromWatchChange (node_modules\@firebase\firestore\dist\index.node.cjs.js:5476:35)
          at PersistentListenStream.onMessage (node_modules\@firebase\firestore\dist\index.node.cjs.js:15743:27)
          at C:\files\react-learning\app-02\test\node_modules\@firebase\firestore\dist\index.node.cjs.js:15676:30
          at C:\files\react-learning\app-02\test\node_modules\@firebase\firestore\dist\index.node.cjs.js:15712:28
          at C:\files\react-learning\app-02\test\node_modules\@firebase\firestore\dist\index.node.cjs.js:14143:20
          at processTicksAndRejections (node:internal/process/task_queues:94:5)
    
    const firebase = require('@firebase/testing')
    
    const MY_PROJECT_ID = 'my-app-id'
    
    describe('my app', () => {
    
        it('can read users', async () => {
    
            const db = firebase.initializeTestApp(
                {
                    projectId: MY_PROJECT_ID,
                    auth: {
                        uid: '1231123', 
                        email: 'someemail@blah.com'
                    }
                }
            ).firestore()
    
            const USER_ID = 'qnWc3u3UjowlF1PCVLSn'
            const testDoc = db.collection('users').doc(USER_ID)
            await firebase.assertSucceeds(testDoc.get())
        })
    })