Any ideas on how to call serverless invoke shell comand from another nodejs script

I’m trying to call serverless command like

serverless invoke local -f hello

but from another nodejs script.
I test it using node child_process spawn

const {spawn} = require ('child_process');
const cmd = 'serverless invoke local -f hello';
const p = spawn (cmd, [], {shell: true});

p.stdout.on ('data', (data) => {
    console.log (data.toString ());

or using exec

const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function main() {
    const { stdout, stderr } = await exec('serverless invoke local -f hello');

    if (stderr) {
        console.error(`error: ${stderr}`);


When I run both solutions from my terminal as

node myscript.js

I can’t get any response, any suggestions or ideas on how to do this will be really helpful