我对 JS 完全陌生,完全被 Node Cheerio 困住了。如果有人可以帮助我,我将不胜感激。
我正在处理的代码在这里:https ://github.com/zafartahirov/bitstarter 。
(找到修复后不起作用的代码将被称为grader.old.js)。
当我跑
node ./grader.js --file index.html --checks checks.json | less
我收到一个错误:
TypeError: Cannot call method 'utf8Slice' of null
at Buffer.toString (buffer.js:416:26)
at exports.isTag (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/lib/utils.js:15:14)
at Function.filter (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/node_modules/lodash/dist/lodash.js:3150:15)
at /home/ubuntu/GitHub/bitstarter/node_modules/cheerio/lib/api/traversing.js:9:26
at Function.reduce (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/node_modules/lodash/dist/lodash.js:3734:25)
at exports.find (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/lib/api/traversing.js:8:17)
at new module.exports (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/lib/cheerio.js:92:18)
at initialize (/home/ubuntu/GitHub/bitstarter/node_modules/cheerio/lib/static.js:23:12)
at checkHtmlFile (/home/ubuntu/GitHub/bitstarter/grader.js:59:23)
at Object.<anonymous> (/home/ubuntu/GitHub/bitstarter/grader.js:76:21)
(END)
有什么建议么?