pdfMake [Cannot read property 'charCodeAt' of undefined]


#1

Hello comunity, please helpme with this big problem.
I want use pdfMake in server side in meteor

It all started when I imported the library with npm
The log sendme error:

Uncaught TypeError: fs.readFileSync is not a function

But in this link meteor I found the solution.
The code is here:

import "pdfmake/build/vfs_fonts.js";
const fs = require('fs');
fs.readFileSync = () => {
    console.log('fs.readFileSync stub called');
};

const pdfMake = require('pdfmake');
console.log(pdfMake);

But I have other error in log.
And I don’t know What to do

The Error in console server side:
Cannot read property 'charCodeAt' of undefined


ALL LOG: SERVER SIDE

[console.log]: fs.readFileSync stub called
(STDERR) C:\Users\Héctor\AppData\Local\.meteor\packages\meteor-tool\1.5.2_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
(STDERR)                                            throw(ex);
(STDERR)                                            ^
(STDERR) 
(STDERR) TypeError: C:\projectZ\node_modules\pdfmake\package.json: Cannot read property 'charCodeAt' of undefined
(STDERR)     at Object.stripBOM (internal/module.js:35:14)
(STDERR)     at Object.Module._extensions..json (module.js:424:48)
(STDERR)     at Module.load (module.js:343:32)
(STDERR)     at Function.Module._load (module.js:300:12)
(STDERR)     at Module.require (module.js:353:17)
(STDERR)     at require (internal/module.js:12:17)
(STDERR)     at npmRequire (C:\projectZ\.meteor\local\build\programs\server\npm-require.js:133:10)
(STDERR)     at Module.useNode (packages\modules-runtime.js:687:18)
(STDERR)     at fileEvaluate (packages\modules-runtime.js:332:20)
(STDERR)     at fileResolve (packages\modules-runtime.js:514:34)

Please Help me. Really, really I need this library
Any Ideas?

I have in package.json:
“pdfmake”: “^0.1.34”


#2

See the documentation for fs.readFileSync, you need to pass in the path of the file you want to read as an argument