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)
I’ve looked through the CLI source code and found an easy workaround until this gets properly patched:
npm install jsonresume-theme-paper
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 forpdf
I still get the initially reported error: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 todist/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:
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:
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.
Published on NPM -> https://www.npmjs.com/package/resume-cli/v/3.0.6
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 runnpm 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:
My problem was that just because I was doing
npm install ./themes/actual
ornpm install ./themes/caffeine
, they weren’t actually getting fully built. I had tocd
into each theme, read thepackage.json
to see what build scripts it had, and then run those (each of which was different, at least foractual
andcaffeine
).This looked promising, but I find I’m still having a (different) error if I try this method. Any run into this?
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