在使用以下方法设置一个简单的应用程序后,我遇到了这个问题:
- 节点 v16.13.2
- npm v8.1.2
- csv-parse v5.0.4 开启
- VSCode v1.63.2
代码是:
const parse = require('csv-parse');
const fs = require('fs');
const results = [];
fs.createReadStream('kepler_data.csv')
.pipe(parse({
comment: "#",
columns: true,
}))
.on('data', (data) => {
results.push(data);
})
.on('error', (err) => {
console.log(err);
})
.on('end', () => {
console.log(results);
console.log('Done!');
});
运行它导致:
index.js:7
.pipe(parse({
^
TypeError: parse is not a function
at Object.<anonymous> (/home/jadeye/node.js_workspace/PLANETS-PROJECT/index.js:7:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
搜索SO给出了类似的结果,但没有实际的解决方案。