KDEconnect command doesn't work with NPM

Hi!

I was trying to open a bash script with a npm command that open a testing browser. It works as expected when I execute it in the terminal or in a bash file, but when I try to execute it with KDEconnect run command it doesn’t work.

Command inside my bash: npm run —-prefix path/to/my/directory dev

Expected behavior: execute the command, open the browser.

Real behavior: nothing happens.

Command to call my bash: path/to/my/bash


Extra Information:

Android KDE Connect version is 1.33.9, downloaded it from PlayStore

Linux KDE Connect version 23.08.5; downloaded from the Software Manager. Linux Mint 22.2

And the NPM command run this .ts file:

const puppeteer = require('puppeteer');
import { Browser, executablePath } from "puppeteer";

const openbrowser = async (url:string) => {
const browser : Browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url)
}

openbrowser("https://duckduckgo.com")

When something works in a terminal but not when launched from another program, then one common cause can be difference in environment.

A terminal runs an interactive shell and some shells source different environment files when run in that mode vs when run as login shells.

For example you could add this line to the beginning of your bash script

env > $HOME/myscript-env.txt

Then run it manually and rename the output file.

Then run it through KDE Connect and compare the two files.

1 Like

OMG! Thank you so much for the explanation. I changed the path on my bash file to include the path of NPM used when the bash is executed in desktop and It fixed the problem! :grin:

1 Like