Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use themes through CLI #408

Open
bkushigian opened this issue Oct 31, 2020 · 33 comments
Open

Cannot use themes through CLI #408

bkushigian opened this issue Oct 31, 2020 · 33 comments

Comments

@bkushigian
Copy link

bkushigian commented Oct 31, 2020

I don't understand the node/js ecosystem, but I've tried all the 'obvious' things and none of these work.

I have a file, resume.json, that I would like to export with a theme, say onepage. I try this:

$ resume export resume.html --theme onepage
callback is not a function
You have to install this theme relative to the folder to use it e.g. `npm install jsonresume-theme-onepage`

I run the command and then try to use the downloaded theme:

$ npm install jsonresume-theme-onepage

+ jsonresume-theme-onepage@0.0.3
added 17 packages from 45 contributors and audited 17 packages in 1.199s

$ resume export resume.html --theme onepage
callback is not a function
You have to install this theme relative to the folder to use it e.g. `npm install jsonresume-theme-onepage`

$ resume export resume.html --theme jsonresume-theme-onepage
callback is not a function
You have to install this theme relative to the folder to use it e.g. `npm install jsonresume-theme-onepage`

$ resume export resume.html --theme node_modules/jsonresume-theme-onepage
callback is not a function
You have to install this theme relative to the folder to use it e.g. `npm install node_modules/jsonresume-theme-onepage`

I've also tried installing things globally, as well as copying my resume.json to node_modules/jsonresume-theme-onepage and exporting from there, but with no luck.

I wasn't able to find docs on how this process is supposed to work...can somebody point me to some docs or tell me what I'm doing wrong?

FWIW I'm on macOS 10.15.4.

@wjr-dev
Copy link

wjr-dev commented Nov 17, 2020

Has it been resolved?
I have the same problem as you!

@TARIQvs
Copy link

TARIQvs commented Nov 17, 2020

I find that one the theme is installed globally it is working properly.

The bellow discussion comment might help you.

Request a theme #7

@thomasdavis
Copy link
Member

I also think this process has been too confusing for a while.

We need a reliable way to people to export from any theme that is on npm or relative to their system.

@DustinWehr
Copy link

I get the same error message when I have a syntax error in my JSON file; so, in my case, the message is clearly wrong.

@nikaro
Copy link

nikaro commented May 7, 2021

Same issue, and my JSON file has no error.

Edit: Actually for me it does not work when i want to export to PDF. HTML export work fine.

@notflip
Copy link

notflip commented Jun 1, 2021

Has anyone found a solution to this? Also having the issue using resume export resume.pdf --format pdf --theme short

@nikaro
Copy link

nikaro commented Jun 1, 2021

Since i'm not fluent in JavaScript i ended up writing my own resume-cli in Python (and converting themes to Jinja).

I wonder if it's caused by "PDF converting engine" not being able to load/execute "external" assets (CSS, JS, pictures) from the theme. I've had similar issues with my tool.

@p2635
Copy link

p2635 commented Aug 15, 2021

I also think this process has been too confusing for a while.

We need a reliable way to people to export from any theme that is on npm or relative to their system.

I want to know how to use this but without knowing how to export in different themes, I can't make use of resume-cli! I'm on Kubuntu 20.10 and I get the same issues as the original poster mentioned here.

Can someone please help?

@tvinhpham
Copy link

tvinhpham commented Sep 16, 2021

Hello,

Here is my WA solution: adding script in package.json file
"scripts": { "export" : "resume export resume.pdf --theme elegant --resume ./tvp.resume.json" }
and run npm run export.
Hope it can help.
Notes: Expected version of NodeJS ">=10.18.1".

@tehciolo
Copy link

tehciolo commented Nov 2, 2021

I've looked through the CLI source code and found an easy workaround until this gets properly patched:

  • install the desired theme locally: npm install jsonresume-theme-paper
  • run the CLI specifying the theme using a relative path: resume export resume.pdf --theme ./node_modules/jsonresume-theme-paper

@thomasdavis
Copy link
Member

I've looked through the CLI source code and found an easy workaround until this gets properly patched:

  • install the desired theme locally: npm install jsonresume-theme-paper
  • run the CLI specifying the theme using a relative path: resume export resume.pdf --theme ./node_modules/jsonresume-theme-paper

Nailed it. Can't think of an easier way to do this myself...?

@geoff-maddock
Copy link

geoff-maddock commented Feb 6, 2022

install the desired theme locally: npm install jsonresume-theme-paper
run the CLI specifying the theme using a relative path: resume export resume.pdf --theme ./node_modules/jsonresume-theme-paper

This looked promising, but I find I'm still having a (different) error if I try this method. Any run into this?

cutups@Hydra-PC:/mnt/c/Users/cutups/code/projects/geoff-maddock.github.io$ resume export resume.pdf --theme ./node_modules/jsonresume-theme-paper
Error: Failed to launch the browser process!
/usr/local/lib/node_modules/resume-cli/node_modules/puppeteer/.local-chromium/linux-818858/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/usr/local/lib/node_modules/resume-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at Interface.<anonymous> (/usr/local/lib/node_modules/resume-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
    at Interface.emit (node:events:402:35)
    at Interface.close (node:readline:586:8)
    at Socket.onend (node:readline:277:10)
    at Socket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) `createPdf` errored out

Done! Find your new .pdf resume at:
 /mnt/c/Users/cutups/code/projects/geoff-maddock.github.io/resume.pd

@davcd
Copy link
Contributor

davcd commented Feb 14, 2022

I was installing the dependency in both local and global context for this to work. Anyway, having to install a theme in the global context doesn't make sense to me.

The problem is that the HTML render access the package in the local context, while the PDF export requires it to be global. With the workaround resume export resume.pdf --theme ./node_modules/my-theme we can get this to work, but I don't think it's intuitive.

IMO theme packages paths should be handled in two ways in the entire project, as a summary:

  • resume export resume.pdf --theme . for development purposes resolving the path join(process.cwd(), 'index.js')
  • resume export resume.pdf --theme my-theme for usage purposes using the path join(process.cwd(), 'node_modules', theme, 'index.js')

I think the access of the package theme should be unified in some point, but by now with the fix in #673 should be working fine.

@thomasdavis
Copy link
Member

Some of you might have much better chance with https://github.com/rbardini/resumed (an alternative CLI)

They specifically mention this problem as something they wanted to fix.

That being said, great ideas @davcd. I will test and merge in your PR now. (#673)

@thomasdavis
Copy link
Member

Published on NPM -> https://www.npmjs.com/package/resume-cli/v/3.0.6

@danielsitnik
Copy link

The only thing that worked for me was @tehciolo suggestion of adding a script to package.json, even with the latest version.

@dynobo
Copy link

dynobo commented Mar 6, 2022

v3.0.6 is not working for me, either. I used the john doe example json with the following commands:

$ sudo npm install -g resume-cli

$ sudo npm install -g jsonresume-theme-even 

$ resume export resume.html --theme even --resume resume.json
(node:256002) UnhandledPromiseRejectionWarning: Error: theme path jsonresume-theme-even could not be resolved from current working directory
    at _default (/usr/local/lib/node_modules/resume-cli/build/render-html.js:46:11)
    at createHtml (/usr/local/lib/node_modules/resume-cli/build/export-resume.js:86:46)
    at module.exports (/usr/local/lib/node_modules/resume-cli/build/export-resume.js:36:5)
    at Command.<anonymous> (/usr/local/lib/node_modules/resume-cli/build/main.js:67:5)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async /usr/local/lib/node_modules/resume-cli/build/main.js:79:3
(node:256002) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:256002) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Some system info:

$ nodejs --version        
v12.22.5

$ npm --version
7.5.2

$ lsb_release -d
Description:	Ubuntu 21.10

Let me know if there is something I can test or in case more information is needed.

(And thanks for this nice project!)

@davcd
Copy link
Contributor

davcd commented Mar 6, 2022

Hello @dynobo, please note that as discussed, themes should be installed in the local context. Please try it:

$ npm install -g resume-cli

$ npm install jsonresume-theme-even 

$ resume export resume.html --theme even --resume resume.json

@dynobo
Copy link

dynobo commented Mar 6, 2022

Thanks for the info, @davcd. Sorry, that I missed that information.
With a local install, it is now working for the html generation, but for pdf I still get the initially reported error:

$ resume export resume.html --theme even --resume resume.json
Done! Find your new .html resume at:
 /home/dynobo/Code/resume/resume.html

$ resume export resume.pdf --theme even --resume resume.json
You have to install this theme relative to the folder to use it e.g. `npm install /home/dynobo/Code/resume/node_modules/jsonresume-theme-even/index.js

@chessmango
Copy link

For what it's worth, I now get the error above for pdf ^ without specifying --theme at all. Reverted to 3.0.5 and all was well at least

@Nezteb
Copy link
Contributor

Nezteb commented Apr 10, 2022

@rbardini @antialias Any ideas? If a contributor were to attempt to fix this in a PR, where should they look?

@Nezteb
Copy link
Contributor

Nezteb commented Apr 10, 2022

Jk, as soon as I started looking at code I figured at least part of it out. Here is a PR to potentially fix this issue: #689

Testing locally it fixes PDF generation. I admittedly never had issues with HTML generation (as long as the themes themselves were fully built).

In my case I have these scripts:

"scripts": {
  "validate": "resume validate",
  "html": "resume export --theme ./themes/actual index.html",
  "pdf": "resume export --theme ./themes/actual resume.pdf",
  "build-caffeine": "cd themes/caffeine && npm install && npm run export",
  "build-actual": "cd themes/actual && npm install && npm run gulp:css && npm run create-html && npm run create-pdf",
  "build": "npm run build-actual && npm run build-caffeine && npm run validate && npm run html && npm run pdf",
  "serve": "resume serve --theme ./themes/actual"
},

My problem was that just because I was doing npm install ./themes/actual or npm install ./themes/caffeine, they weren't actually getting fully built. I had to cd into each theme, read the package.json to see what build scripts it had, and then run those (each of which was different, at least for actual and caffeine).

@rbardini
Copy link
Contributor

v3.0.7 has been released with #689, which might fix this issue.

@gillbates
Copy link

v3.0.7 got still the same problem

resume export resume.pdf --theme ./node_modules/jsonresume-theme-even

it shows here

You have to install this theme relative to the folder to use it e.g. npm install /Users/xxx/Desktop/resume/node_modules/jsonresume-theme-even/index.js

@github-account1111
Copy link

Wait I might be missing something, but considering this has been an issue for well over a year, what's the point of this whole JSON Resume project if you can't use a theme and therefore can't export to PDF?
I doubt any employer would actually take your literal JSON file.

@rbardini
Copy link
Contributor

Looks like the problem is between resume-cli and jsonresume-theme-even. (and potentially other themes)

More specifically, resume-cli currently assumes that themes are always exported from an index.js file, while the entry point to a module can be arbitrary. When the theme was migrated to ESM in rbardini/jsonresume-theme-even@de801d2, its CJS entry point moved to dist/index.cjs, and resume-cli cannot find it anymore. See rbardini/jsonresume-theme-even#12. (thanks @jessejoe for investigating!)

A possible fix could be requiring the "bare" theme specifier when it's not a local theme:

   if (theme[0] === '.') {
     theme = path.join(process.cwd(), 'index.js');
     theme = path.join(process.cwd(), theme, 'index.js');
-  } else {
-    theme = path.join(process.cwd(), 'node_modules', theme, 'index.js');
   }
   try {
     const themePkg = require(theme);

so that Node.js resolves the correct file based on the required module's main field.

Of course this change could break something else, as has been happening throughout this issue. I highly recommend anyone facing this to give Resumed a try, since one of its main benefits compared to resume-cli is the improved theme resolution.

@nvegater
Copy link

After multiple workarounds for other steps (like the pupeteer installation) still I'm not able to generate PDF's out of a valid resume (html works with themes).

I'm getting the same "relative folder theme installation" error as #408 (comment).

Resumed doesn't support pdf generation either unfortunately.

Remove the PDF generation functionality from the Docs if it's not working please, it will save people a lot of time.

@DustinWehr
Copy link

@nvegater my approach was to make some small edits to an existing theme (kendall) that makes html-to-pdf programs work better. I then made a script to streamline uploading the html file to a page where I can use https://tools.pdf24.org/en/webpage-to-pdf on it (it's the only service I found that has no downsides). If it interests you I can dig up the necessary edits.

If it were up to me, I'd update the docs to recommend using PDF24.

@0xMoJo7
Copy link

0xMoJo7 commented Aug 17, 2022

Same issue with the PDF for multiple themes, the HTML export works fine. Thanks for the recommendation @DustinWehr

@nvegater
Copy link

I have tried pdf24 as well and it generates very good PDF's but with a few CSS errors. Are those the edits you mean ? If yes, I am very interested :) Thank you for the tips!

If it interests you I can dig up the necessary edits.

@DustinWehr
Copy link

DustinWehr commented Aug 18, 2022

@nvegater I didn't document the changes, but I believe these are a superset (inclusion of index.js might be unnecessary) of the only files I touched from the directory jsonresume-theme-kendall. https://www.cs.toronto.edu/~wehr/jsonresume-theme-kendall__modified_files.zip.
I say "I believe" because that was crudely inferred by comparing the unmodified version 0.1.19 of the theme that I have on my computer to my modification of version 0.2. Hope it saves you some time.

@clevertension
Copy link

For what it's worth, I now get the error above for pdf ^ without specifying --theme at all. Reverted to 3.0.5 and all was well at least

yes, 3.0.5 is worked as expected in pdf generation

@janglade
Copy link

For my case I solved the problem of exporting to html with :
npx jsonresume-theme-even < resume.json > resume.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests