resume-cli: Cannot use themes through CLI

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.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 23
  • Comments: 32 (10 by maintainers)

Most upvoted comments

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

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

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

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.

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

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.

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)

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

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

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

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

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

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.

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

The bellow discussion comment might help you.

Request a theme #7