I'm trying to run a shell script with node.js using spawn of child_process, this works fine, but I need to use some functions created on my .bashrc, let's call it testAll, this is de definition of my function on .bashrc:
testAll() {
echo "I am running the function"
}
export -f testAll()
If I call testAll from cmd all works fine, but if I call:
const child = spawn("testAll", [], { shell: "/bin/bash" });
I receive an error: /bin/bash: testAll: command not found
I already tried to run this command from a shell script like this:
const child = spawn("./test.sh", [], { shell: "/bin/bash" });
The script:
#!/bin/bash
shopt -s expand_aliases
source /home/myuserhere/.bashrc
echo "teste"
testAll
echo shows fine, but I got the same error whit testAll.
I already tried without source, without shopt and with bash ./test.sh and always receive this same error.
Can anyone help me with this tricky error?