#Can not import tauri api shell
1 messages · Page 1 of 1 (latest)
are you using any frameworks?
or just HTML CSS JS
only html css js
no npm right?
then modular imports won't work
use the global tauri
ok, how do i do that?
then you have acccess to window.__TAURI__.shell.Command
I would recommend using a framework
because that's better than reinventing the wheel
ok, i have managed to import it this way, last question, how do I run a command that I have setup in tauri config, in shell scope?
I never used js to run commands (I am kinda rust mainly)
sadly I can't help
I see, well still, thank you for helping me import it
You're welcome
Assuming you have const Command = window.__TAURI__.shell.Command;, take the example from the docs and remove the first line.
The name you set in the config is what you provide as the first input, the second input can be an array of args or a string for a single argument. For example, one argument is new Command("rust_crate_manager", "--version") and multiple arguments are formatted as new Command("rust_crate_manager", ["tauri", "--version"]).
The args are optional as well, you don't have to provide them, as the example shows. There's a third input which is also optional that lets you set a few details like the working directory, the character encoding, and the environment variables.
Thanks, i managed to figure that out, right now i am trying to get the output of command
Did you run it with .spawn() or .execute()?