I am attempting to read content from a PDF file using Node with the Pdfreader module, but it is giving me the following error in the terminal:
(node:31780) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.(Use node --trace-warnings ...
to show where the warning was created)/Users/Zayan/index.js:1import { PdfReader } from "pdfreader";^^^^^^
SyntaxError: Cannot use import statement outside a moduleat internalCompileFunction (node:internal/vm:128:18)at wrapSafe (node:internal/modules/cjs/loader:1279:20)at Module._compile (node:internal/modules/cjs/loader:1331:27)at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)at Module.load (node:internal/modules/cjs/loader:1205:32)at Module._load (node:internal/modules/cjs/loader:1021:12)at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)at node:internal/main/run_main_module:28:49
This is my index.js so far (I have not created any files other than this and it is stored in my user folder):
import {PdfReader} from "pdfreader";new PdfReader().parseFileItems("600067301-2024-04-03.pdf",(err,item) => { if(err) console.log(error) else if (!item) console.warn("end of file") else if (item.text) console.log(item.txt)})