bsorrentino / pdf-tools

Extract Markdown + Images from PDF
MIT License
42 stars 5 forks source link

Error: Cannot find module './bin/index' #5

Closed poorpaper closed 2 years ago

poorpaper commented 2 years ago

I really appreciate this project, but when I finish the installation, using the pdftools pdf2md command shows the error Error: Cannot find module '. /bin/index' in detail:

Error: Cannot find module './bin/index'
Require stack:
- E:\pdf-tools-1.0.1\pdf-tools-1.0.1\cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (E:\pdf-tools-1.0.1\pdf-tools-1.0.1\cli.js:3:14)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'E:\\pdf-tools-1.0.1\\pdf-tools-1.0.1\\cli.js' ]
}

How can I solve it? Did I make a mistake in any step? Thanks in advance.

bsorrentino commented 2 years ago

Hi @poorpaper

  1. Which version of node are you using ?
  2. Did you have installed package globally (-g) ?
  3. Did you try to uninstall and install again ?

Let me know

poorpaper commented 2 years ago

Hello, @bsorrentino .Thanks for the reply,

  1. node version is 16.16.0
  2. I have installed package with the command npm install ./pdf-tools -g
  3. I have uninstalled it with the command npm remove ./pdf-tools -g and reinstalled with npm install ./pdf-tools -g, after I run pdftools pdf2md it shows the same error. I'm sorry that I'm not familiar with node.js.
bsorrentino commented 2 years ago

Hi @poorpaper no problem

remove all and try

npm install @bsorrentino/pdf-tools -g

and let me know

poorpaper commented 2 years ago

Thank you @bsorrentino , I have tried that command and it works! But it shows the information below after I run the command pdftools pdf2md E:\test\Docker.pdf -o E:\test\output :

monospace or code font doesn't exists!
monospace or code font doesn't exists!
monospace or code font doesn't exists!
monospace or code font doesn't exists!
monospace or code font doesn't exists!
monospace or code font doesn't exists!
WARN: file Docker\Docker.fonts.json already exists!

The document contains Chinese, is this the cause of the error?

bsorrentino commented 2 years ago

Hi @poorpaper that's normal

the font mapping is your responsibility for this reason the tool generates the Docker.fonts.json file

message monospace or code font doesn't exists! means that tool has detected code block but doesn't find the font mapping.

However now it works! 👍🏻