好的,我偶然发现了这个奇怪的错误。我正在使用 cradle CouchDB 连接器,当我传入 k (typeof -> string) 时它可以工作,但是当我取消注释行时 k = k.toLowerCase(); 它在下面的代码下方给了我错误。
代码:
JSON.parse(fs.readFileSync('dictionary/dictionary.json', 'utf8'), function(k, l){
//k = k.toLowerCase();
db.save(k, {
definition: l
}, function(err, res) {
console.log('Error: ' + err);
console.log(res);
});
entry++;
});
错误:
/usr/local/nginx/html/whois.dev/node_modules/cradle/lib/cradle/cache.js:37
if (entry.document.toJSON) {
^
TypeError: Cannot read property 'toJSON' of undefined