cakebake / markdown-themeable-pdf

ARCHIVED. NOT MAINTAINED. Themeable Markdown Converter (Print to PDF, HTML, JPEG or PNG)
https://atom.io/packages/markdown-themeable-pdf
133 stars 37 forks source link

Uncaught AssertionError: html-pdf: Failed to load PhantomJS module. You have to set the path to t... #17

Closed bertdv closed 8 years ago

bertdv commented 8 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.0.19 System: Microsoft Windows 7 Enterprise Thrown From: markdown-themeable-pdf package, v0.10.1

Stack Trace

Uncaught AssertionError: html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'

At assert.js:89

AssertionError: html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'
  at new PDF (C:\Users\bdevries\.atom\packages\markdown-themeable-pdf\node_modules\html-pdf\lib\pdf.js:41:7)
  at Object.exports.create (C:\Users\bdevries\.atom\packages\markdown-themeable-pdf\node_modules\html-pdf\lib\index.js:13:14)
  at C:\Users\bdevries\.atom\packages\markdown-themeable-pdf\lib\markdown-themeable-pdf.js:447:27
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

Commands

  2x -8:26.7.0 core:move-left (atom-text-editor.editor.is-focused)
  5x -8:22.1.0 core:backspace (atom-text-editor.editor.is-focused)
  3x -7:24.4.0 core:move-down (atom-text-editor.editor.is-focused)
 11x -7:09.9.0 core:backspace (atom-text-editor.editor.is-focused)
  2x -6:51.3.0 core:move-down (atom-text-editor.editor.is-focused)
  9x -6:43.8.0 core:backspace (atom-text-editor.editor.is-focused)
  5x -6:01.5.0 core:move-up (atom-text-editor.editor.is-focused)
  2x -6:00.5.0 core:move-down (atom-text-editor.editor.is-focused)
     -5:59.7.0 core:move-right (atom-text-editor.editor.is-focused)
     -5:59.1.0 core:move-up (atom-text-editor.editor.is-focused)
 21x -5:58.8.0 core:move-right (atom-text-editor.editor.is-focused)
     -5:53.4.0 core:backspace (atom-text-editor.editor.is-focused)
  9x -5:52.9.0 core:move-left (atom-text-editor.editor.is-focused)
     -5:50.7.0 core:backspace (atom-text-editor.editor.is-focused)
     -4:32.8.0 settings-view:install-packages-and-themes (atom-text-editor.editor.is-focused)
     -4:20.2.0 core:confirm (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {
    "themes": [
      "spacegray-mocha-ui",
      "atom-light-syntax"
    ],
    "disabledPackages": [
      "language-gfm"
    ]
  }
}

Installed Packages

# User
language-ipynb, v1.3.0
markdown-themeable-pdf, v0.10.1
spacegray-mocha-ui, v0.2.0

# Dev
No dev packages
cakebake commented 8 years ago

Please try to reinstall markdown-themeable-pdf and check your firewall settings.

cakebake commented 8 years ago

If the error is still up to date, write in this Ticket

MafiaInc commented 8 years ago

I have the same issue using Atom 1.0.11 in Linux/Fedora 23. I tried to reinstall after disabled firewall, no success.

cakebake commented 8 years ago

Strange, I have Fedora 23, too.

Myasuka commented 8 years ago

I also meet the same error, which tells me You have to set the path to the PhantomJS binary using 'options.phantomPath'. I fix this error by using npm install html-pdf in command prompt. Hope it works for you.

ChopperLin commented 8 years ago

I'm using openSUSE Tumbleweed, after a long wait to install this package, and also have this problem. Re-installation doesn't do any help.

cakebake commented 8 years ago

Sorry, but I can not do more than writing the package compliant :/ Unfortunately, the problems must be on your OS, Node, or atom installation

yonglei commented 8 years ago

I am having the same problem on Windows10 64-bit, could anybody give some hint to fix it?

JonnyCBB commented 8 years ago

@yonglei I had the same problem just now on my Windows 10 64-bit machine. I managed to fix it following the instructions given by @Myasuka:

  1. Make sure you have npm installed on your machine. If you don't have it you can download it from here (Node.js comes packaged with npm and I read that it was the easiest way to get npm.
  2. Open your command prompt and run the command npm install html-pdf
    One of the lines from the log should tell you where the PhantomJS binary is located:
Done. Phantomjs binary available at C:\Users\jonathan\node_modules\html-pdf\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe
  1. Add the binary to your path.
  2. Restart Atom

This worked for me. I hope it works for you too.

bowang14 commented 8 years ago

@Myasuka @JonnyCBB I got the location of PhantomJS binary. May you please tell me how to 'Add the binary to your path'? Thank you so much.

JonnyCBB commented 8 years ago

Hey @bowang14, sorry for late reply. Assuming you're on a Windows machine here's how to add a binary to your path:

  1. Right click the Windows icon in the bottom right corner of your screen
  2. Select "Control Panel"
  3. You'll get a screen with lots of options. Select "System"
  4. On the new screen select "Advanced system settings"
  5. In the new window that pops up, select "Environment Variables..."
  6. Then you'll get another new window with two boxes: one for "User variables" and one for "System variables". If you're using a personal machine where you're the only user then there's practically no difference using either. Scroll down the list in the "System variable" box until you see "Path" in the "Variable" column. Click on "Path" and then click "Edit..." below.
  7. If you're using Windows 10 then you'll have a nice interface to modifying your path. You can click "New" and then enter the path to the Phantom JS binary that you were given when prompted. Otherwise if you're using like Windows 7 or earlier (I can't remember what Windows 8 was like) then you'll have a nasty long string of paths separated by semicolons. You'll have to scroll to the end, add a semicolon and then add the path. 8, Click "Ok" to everything and then you should be good to go.

I hope this works for you :)

bowang14 commented 8 years ago

@JonnyCBB Thank you for your reply and I have to say sorry that I forgot to tell you I use a Mac. Thank you so much for your help all the same.

I found a way via Google and had already add it to my path. However, it doesn't work still.

[bogon:~ wangbo$ echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:**/Users/wangbo/node_modules/html-pdf/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs**:/Library/TeX/texbin

Is there any mistake I made?

Again thank you so much.

JonnyCBB commented 8 years ago

I have to admit that I know least about Macs.

What error message do you get? Is it the same as before?

bowang14 commented 8 years ago

Yes, exactly the same one.

JonnyCBB commented 8 years ago

@bowang14 I've been trying to reproduce the error but unfortunately I can't so I'm not quite sure what the problem is. Sorry :(

bowang14 commented 8 years ago

@JonnyCBB Thank you so so so much for your help all the same.

bowang14 commented 8 years ago

I made it by........just re-installing Atom. sigh

JonnyCBB commented 8 years ago

I'm glad that you got it working.

mountzf commented 8 years ago

@JonnyCBB @bowang14 It works for me well and I maybe understand more about environment variables. Thank you.

vbay commented 8 years ago

我也遇到同样问题,根据以上评论,记录一下解决过程。 atom markdown转换PDF 解决AssertionError: html-pdf: Failed to load PhantomJS module http://blog.csdn.net/dream_an/article/details/51800523

explosic4 commented 7 years ago

I tried adding the PhantomJS binary to my environment path, but it doesn't work. However, I fixed it by directly copy the html-pdf folder created by npm install html-pdf to ~/.atom/packages/markdown-themeable-pdf/node-modules and overwrite the previous html-pdf folder.

guojuntang commented 7 years ago

Well,I have the same problem and try to set the path manually. Firstly,download the phantomjs: npm install phantomjs or cnpm install phantomjs and you will see Done. Phantomjs binary available at C:\Users\Kael\AppData\Roaming\npm\node_modules\.phantomjs_npminstall\phantomjs\2.1.7\phantomjs\lib\phantom\bin\phantomjs.exe copy the path and find this js file: C:\Users\Kael\.atom\packages\markdown-pdf\node_modules\html-pdf\lib\PDF.js paste the path and write: this.options.phantomPath = "C:\\Users\\Kael\AppData\\Roaming\\npm\\node_modules\\.phantomjs_npminstall\\phantomjs\\2.1.7\\phantomjs\\lib\\phantom\\bin";

done.

xwsg commented 7 years ago

ubuntu 16.04 Atom 1.9.2

  1. Make sure you have installed nodejs,
  2. Run sudo npm install -g phantomjs-prebuilt
  3. Reinstall markdown-themeable-pdf,
  4. Restart Atom
  5. Enjoy it!
miniwark commented 7 years ago

Same problem here on ubuntu 16.04 Atom 1.12.05

At last, add a recommended procedure to install PhantomJs on the Readme file ? Because it's seems like to be a prerequisite for this package.

JonnyCBB commented 7 years ago

I don't use ubuntu so I can't say for certain that the procedure worked for me but I guess you submit this to the package author as a pull request.

CharlSteynberg commented 7 years ago

It was really easy to fix on Linux:

This worked for me without any issues, thanks for this amazing package @cakebake

strongbugman commented 7 years ago

On my macOS:

xinjiang393 commented 7 years ago

@CharlSteynberg

xinjiang393 commented 7 years ago

@CharlSteynberg

xinjiang393 commented 7 years ago

@CharlSteynberg

youngjuning commented 7 years ago

@explosic4 原来是因为缺少包啊

mmtou commented 7 years ago

我也遇到了这个问题,卸载后重启atom,然后重新安装,然后重启atom就可以用了

youngjuning commented 7 years ago

npm install -g html-pdf npm install -g phantomjs

mohammedSlimani commented 4 years ago

I dont know why, but using yarn instead of npm seems to solve my problem