Skip to content

run pdf-parse v2.4.5 error #114

@wuxiaolan91

Description

@wuxiaolan91

windows platoform: win 64
nodejs version: v22.12.0
pdf-parse version: 2.4.5

my nodejs code:

const fs = require("fs");
const { default: pdf } = require("pdf-parse"); // 必须这样写

const data = fs.readFileSync("./test.pdf");

pdf(data).then((res) => {
  console.log(res.text); // 提取到的文本
});

When I run my above nodejs code will to error:

D:\practice\2026\04\node0413.js:6
pdf(data).then((res) => {
^

TypeError: pdf is not a function
at Object. (D:\practice\2026\04\node0413.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1565:14)
at Object..js (node:internal/modules/cjs/loader:1708:10)
at Module.load (node:internal/modules/cjs/loader:1318:32)
at Function._load (node:internal/modules/cjs/loader:1128:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions