How to run grunt from a PHP script?

I'm trying to execute grunt in a local project from a php script.

I have npm and the grunt cli installed globally.

If I open up terminal and enter:

cd /path/to/local/grunt/project/ && grunt

Grunt will run successfully and carry out the tasks I've set in the gruntfile.js found in that directory.

However, when I try to shell exec the same thing via a php script

var_dump(shell_exec('cd /path/to/local/grunt/project/ && grunt 2>&1'));

I get:

sh: grunt: command not found

I've also tried the direct path to the global CLI:

var_dump(shell_exec('/usr/local/lib/node_modules/grunt-cli/bin/grunt 2>&1'));

but then I get:

env: node: No such file or directory

However this runs as expected from terminal.

What's going on here? Why is the grunt command not found when I try to run it via php? How can I shell exec or exec grunt from a php script?