Export problem
Chivier opened this issue · comments
Exporting is not available on MacOS.
I guess there are several lines should be modified in src/export.ts
:
- file path problem: normalizePath in obsidian can only fix path in the obsidian vault. When it normalize a path in MacOS or Linux, the heading '/' would be removed. More details are listed in this website: normailzePath removes a leading slash. I personally recommend to use
normalize
frompath
. - npx executing problem on MacOS. I fixed the path problem on my laptop. But there is another problem like this:
The second problem is frustrating. I tried to use marp-CLI-API. But there are some TS problems that I do not understand.
Anyway, I tried to fix this, but I failed. However, I still love this extension and feel free to contact me if you need help with debugging or testing.
@Chivier
Thank you for your comment!
About normalize
I decided to use the one from path
as you mentioned. (I have tested it on Linux.) #12
About npx
Generally npx
is installed with npm
when you install nodejs, but if you can't use it, the following command may help.
npm i -g npx
Could you please give it a try?
In case you still can't execute, I have the following solution in mind.
- Use
npm exec --
instead ofnpx
. - Allow the user to choose from the configuration whether to use
npx
or the globally installedmarp-cli
.- I think that by manually running
npm i -g @marp-team/marp-cli
, this plugin will be able to use themarp
command.
- I think that by manually running
- ... Or is there any other way?
Hmm, the problem is still not solved, and I am also confused about environment on MacOS.
How do I debug
I modified the command execution part in src/export.ts
:
So, I can get the stderr & stdout in obsidian.
Problem
But it is odd here. In a common shell, I do have marp-cli
and npx
:
And /bin/sh seems healthy too:
But in obsidian, it seems a little bit strange that npx
is not available.
@Chivier
I borrowed a Mac from a friend to try it out and can confirm that I have the same problem.
I found this issue: electron/electron#7688
sindresorhus/fix-path may fix this problem.
Unfortunately, I do not own a Mac, so if you could try this it would be greatly appreciated.
The problem also happens on Windows. (Previously I thought the problem was related to "/"
in path but after updating to 1.2.0 still not functioned). After clicking (any one of) the export button, I can see a file with ".tmp" quickly created in my download folder but then it gets deleted and nothing left.
The problem also happens on Windows. (Previously I thought the problem was related to
"/"
in path but after updating to 1.2.0 still not functioned). After clicking (any one of) the export button, I can see a file with ".tmp" quickly created in my download folder but then it gets deleted and nothing left.
Just to be sure, can you run npx
with node.js installed?
Can you run npx -v
and see if the version is displayed?
@Chivier
You may be able to work around this by adding node:process
or node:os
to external
in esbuild.config.mjs
.
@Chivier You may be able to work around this by adding
node:process
ornode:os
toexternal
inesbuild.config.mjs
.
It works! But there is something else now. I am checking it:
Sorry 😥, I can't install node.js on my Windows PC because it is governed by my company and installing node.js needs administrator rights. (And I'm not a developer so not quite familiar with npx
)
@AndyLiu9
Oh, I see. 😢
This plugin uses marp-cli to export slides to a file, and marp-cli requires Node.js (or Docker) to work. And since attempts to call marp-cli directly from this plugin have failed, this is the only known method at this time.
The npx
command is installed with the Node.js installation. This plugin runs marp-cli via this command.
In summary, a Node.js installation is required to export slides.