Npm package pdf2json not getting installed


I am trying to work with pdf2json package in meteor.I installed using meteor npm install command which completed successfully.But while calling the function from module is giving error.

import { Meteor } from 'meteor/meteor';
import fs from 'fs';

//import pdfParser from 'pdf2json';
pdfParser = Npm.require('pdf2json');

Future = Npm.require('fibers/future');

Meteor.startup(() => {
  // code to run on server at startup
  console.log("\n *START* \n");
  future = new Future();

  let pdfParser = new PDFParser();
//var content = fs.readFile("sample.pdf");
fs.readFile("sample.pdf", (err, pdfBuffer) => {
  if (!err) {
//console.log("Output Content : \n"+ content);
console.log("\n *EXIT* \n");

the error i am getting is

ReferenceError: PDFParser is not defined
W20170213-11:12:31.433(5.5)? (STDERR)     at server/main.js:15:23

to check i added another npm package future, iam able to call its fuction properly.

Can anybody please help me with this?


Well, as you added the package using this:

pdfParser = Npm.require('pdf2json');

you should have referenced it correctly here:

let pdfParser = new PDFParser();

I suggest:

import PDFParser from 'pdf2json';

which should get your variable names lined up.


I feel so stupid about this error.
Thanks alot for taking time to point it out.


You’re welcome. It’s happened to all of us at some time.