#Can not import tauri api shell

1 messages · Page 1 of 1 (latest)

quasi bone
#

in main.js file I' ve put: "import { Command } from '@tauri-apps/api/shell'; " but when i run the app I get this error: "[Error] TypeError: Module name, '@tauri-apps/api/shell' does not resolve to a valid URL."

queen mountain
#

or just HTML CSS JS

quasi bone
#

only html css js

queen mountain
#

then modular imports won't work

#

use the global tauri

quasi bone
#

ok, how do i do that?

queen mountain
#

then you have acccess to window.__TAURI__.shell.Command

#

I would recommend using a framework

#

because that's better than reinventing the wheel

quasi bone
#

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?

queen mountain
#

sadly I can't help

quasi bone
#

I see, well still, thank you for helping me import it

queen mountain
real ruin
#

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.

quasi bone
#

Thanks, i managed to figure that out, right now i am trying to get the output of command

real ruin
#

Did you run it with .spawn() or .execute()?