在vscode

时间:2017-05-26 21:09:41

标签: javascript node.js visual-studio-code firebase-admin

使用firebase-admin 5.0.0,我在运行节点7.10.0的vscode 1.12.2中调试时出现此异常

Exception has occurred: Error
SyntaxError: Unexpected token ɭ in JSON at position 0
    at Object.parse (native)
    at eb (c:\Users\...\node_modules\firebase-admin\lib\database\database.js:57:267)
    at wc (c:\Users\...\node_modules\firebase-admin\lib\database\database.js:77:489)
    at yc (c:\Users\...\node_modules\firebase-admin\lib\database\database.js:77:708)
    at kh.h.hf (c:\Users\...\node_modules\firebase-admin\lib\database\database.js:224:146)
    at c:\Users\...\node_modules\firebase-admin\lib\database\database.js:239:186
    at c:\Users\...\node_modules\firebase-admin\lib\firebase-app.js:82:25
    at Array.forEach (native)
    at c:\Users\...\node_modules\firebase-admin\lib\firebase-app.js:81:43
    at process._tickCallback (internal/process/next_tick.js:109:7)

这是我正在运行的javascript

'use strict';

if (!process.env.FIREBASE_PROJECT_ID) {
  require('dotenv').config({ silent: true });
}

const fbConfig = require('./firebase-config');
const admin = require('firebase-admin');

admin.initializeApp({
  credential: admin.credential.cert(fbConfig.FIREBASE_SERVICE_ACCOUNT),
  databaseURL: fbConfig.APP_SETTINGS.databaseURL
});

const db = admin.database();

let obj = {foo:'bar'};

let ref = db.ref('test');

ref.set(obj, function (error) {
  console.log(error);
  console.log('complete');
});

在database.js中发生异常

function eb(a) { 
  return "undefined" !== typeof JSON && n(JSON.parse) ? JSON.parse(a) : xa(a) 
}

当我点击异常时,我可以看到a的值是“ɭ ”。如果我继续,则抛出另一个类似的异常,并且操作最终成功完成,错误值为null。

知道这里发生了什么吗?

0 个答案:

没有答案