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

CLI invalid options trigger an hard-to-understand stacktrace #198

Open
f18m opened this issue Oct 30, 2023 · 5 comments
Open

CLI invalid options trigger an hard-to-understand stacktrace #198

f18m opened this issue Oct 30, 2023 · 5 comments

Comments

@f18m
Copy link

f18m commented Oct 30, 2023

Hi all,
I'm trying to use asciidoctor (on top of npm) to produce HTML documentation.
Working on RHEL I managed to install successfully:

npm install -g asciidoctor

but then launching the tool I get the following error:

[root@fedora libzmq-f18m]# asciidoctor -D /tmp/mytest -azmq_version='4.3.6' doc/*.adoc
require 
backend undefined
doctype undefined
standalone false
section-numbers false
failure-level FATAL
quiet true
verbose true
timings false
trace false
base-dir undefined
destination-dir /tmp/mytest
template-dir undefined
template-engine undefined
verbose-mode 0
attributes 
options {"safe":"unsafe","standalone":false,"failure_level":4,"verbose":0,"timings":false,"trace":false,"to_dir":"/tmp/mytest","to_file":"-","attributes":[""]}
node:internal/modules/cjs/loader:1077
  const err = new Error(message);
              ^

Error: Cannot find module ''
Require stack:
- /usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js
- /usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/cli.js
- /usr/local/lib/node_modules/asciidoctor/bin/asciidoctor
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Function.resolve (node:internal/modules/cjs/helpers:125:19)
    at Invoker.requireLibrary (/usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js:126:29)
    at /usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js:135:29
    at Array.forEach (<anonymous>)
    at Invoker.prepareProcessor (/usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js:134:20)
    at Invoker.invoke (/usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js:24:13)
    at Object.<anonymous> (/usr/local/lib/node_modules/asciidoctor/bin/asciidoctor:9:22)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/invoker.js',
    '/usr/local/lib/node_modules/asciidoctor/node_modules/@asciidoctor/cli/lib/cli.js',
    '/usr/local/lib/node_modules/asciidoctor/bin/asciidoctor'
  ]
}

Node.js v18.18.2

I have no clue how to fix it.... any hint?
thanks

PS: I cannot use "dnf install asciidoctor" because actually I'm trying to get Asciidoctor working on readthedocs.io that requires Asciidoctor to be installed through npm

@mojavelinux
Copy link
Member

The problem you are running into is that you have given the processor a whole bunch of invalid options by including this in the command:

-azmq_version='4.3.6'

While the CLI should probably be more clear about the invalid option, that is the cause. You can fix it by adding a space after the -a so it is seen as a single option:

-a zmq_version='4.3.6'

Also, instead of installing the asciidoctor npm package globally, I recommend the following instead:

npx asciidoctor doc/*.adoc

npx manage the installation for you on demand so you don't have to worry about where it gets installed.

@f18m
Copy link
Author

f18m commented Oct 31, 2023

Hi @mojavelinux ,

thanks a lot for the quick answer!
Indeed using:

-a zmq_version='4.3.6'

it works fine!

Can I just rename this bug to "CLI invalid options trigger an hard-to-understand stacktrace" ?
Because without your help I would have never understood that the stacktrace I was getting was just because of a missing whitespace :)

@mojavelinux
Copy link
Member

I'm glad that worked!

As to whether to rename the issue or to file a new one, that's up to @ggrossetie.

@f18m f18m changed the title Cannot find module '' CLI invalid options trigger an hard-to-understand stacktrace Oct 31, 2023
@f18m
Copy link
Author

f18m commented Oct 31, 2023

for now I renamed this issue, @ggrossetie please let me know if that's not ok and I should close this and open a new one instead, thanks.

@ggrossetie
Copy link
Member

I'm fine with it, thanks for your help Dan!

@ggrossetie ggrossetie transferred this issue from asciidoctor/asciidoctor.js Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants