resume-cli icon indicating copy to clipboard operation
resume-cli copied to clipboard

Cannot use themes through CLI

Open bkushigian opened this issue 3 years ago • 32 comments

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

+ [email protected]
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.

bkushigian avatar Oct 31 '20 03:10 bkushigian

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

wjr-dev avatar Nov 17 '20 05:11 wjr-dev

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

The bellow discussion comment might help you.

Request a theme #7

TARIQvs avatar Nov 17 '20 09:11 TARIQvs

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.

thomasdavis avatar Nov 17 '20 12:11 thomasdavis

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.

DustinWehr avatar Jan 15 '21 20:01 DustinWehr

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.

nikaro avatar May 07 '21 08:05 nikaro

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

notflip avatar Jun 01 '21 07:06 notflip

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.

nikaro avatar Jun 01 '21 07:06 nikaro

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?

p2635 avatar Aug 15 '21 14:08 p2635

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".

tvinhpham avatar Sep 16 '21 13:09 tvinhpham

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

tehciolo avatar Nov 02 '21 07:11 tehciolo

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...?

thomasdavis avatar Nov 04 '21 13:11 thomasdavis

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

geoff-maddock avatar Feb 06 '22 21:02 geoff-maddock

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.

davcd avatar Feb 14 '22 21:02 davcd

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. (https://github.com/jsonresume/resume-cli/pull/673)

thomasdavis avatar Feb 15 '22 10:02 thomasdavis

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

thomasdavis avatar Feb 15 '22 10:02 thomasdavis

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

danielsitnik avatar Mar 03 '22 13:03 danielsitnik

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!)

dynobo avatar Mar 06 '22 19:03 dynobo

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

davcd avatar Mar 06 '22 20:03 davcd

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

dynobo avatar Mar 06 '22 20:03 dynobo

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

chessmango avatar Apr 08 '22 12:04 chessmango

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

Nezteb avatar Apr 10 '22 19:04 Nezteb

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: https://github.com/jsonresume/resume-cli/pull/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).

Nezteb avatar Apr 10 '22 20:04 Nezteb

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

rbardini avatar Apr 20 '22 13:04 rbardini

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

gillbates avatar Apr 30 '22 15:04 gillbates

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.

github-account1111 avatar May 03 '22 22:05 github-account1111

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@de801d202788b976b6c89e7366b04d8162020b32, 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.

rbardini avatar May 21 '22 16:05 rbardini

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 https://github.com/jsonresume/resume-cli/issues/408#issuecomment-1114010907.

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.

nvegater avatar Aug 16 '22 20:08 nvegater

@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.

DustinWehr avatar Aug 16 '22 22:08 DustinWehr

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

0xMoJo7 avatar Aug 17 '22 03:08 0xMoJo7

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.

nvegater avatar Aug 17 '22 06:08 nvegater