我有一个> 200行CSV文件,Node的readline模块会在文档末尾抛出此错误:
has no method 'on'
at new Interface (readline.js:107:11)
at Object.exports.createInterface (readline.js:41:10)
该文档的末尾有一个空行,是否会导致问题?
request('http://csvdata.com/csvfile', function (error, response, csvData) {
// If Request Successful
if (!error && response.statusCode == 200) {
// Defaults
var instream = csvData;
var outstream = new stream;
var rl = readline.createInterface(instream, outstream);
// Go through each line
rl.on('line', function(line) {
console.log(line);
});
答案 0 :(得分:0)
我遇到了同样的问题
我所看到的是" readline"是2个不同的模块,
1.引用https://www.npmjs.org/package/readline(外部模块)
2.参考http://nodejs.org/api/readline.html(核心模块)
然后" on"外部模块https://www.npmjs.org/package/readline支持该方法。
看看这是否有帮助