Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

553
Visualizações
TypeError: parse is not a function on csv-parse

I ran into this issue after setting up a simple app using:

  • node v16.13.2
  • npm v8.1.2
  • csv-parse v5.0.4
    On
  • VSCode v1.63.2

Code is:

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!');
    });

Running it resulted in:

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)

Searching SO gave similar results but no actual solution.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Solution was simple. If parse or any other function is not recognized with node require, try getting the function itself as:

const { parse } = require('csv-parse');

Something worth noting it the color scheme that emphasizes the difference between the const parse color = white, and the usage of the function parse inside pipe = green.

errornous call

And the colors without error where const { parse } is green, matchin the const call.

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório

0

Instead of using

const { parse } = require('csv-parse');

Try Following

const { parse } = require("csv-parse");

about 4 years ago · Juan Pablo Isaza Relatório

0

get the parse function it self in the csv-parse module by doing const {parse} = require("csv-parse");

and call .pipe(parse())

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda