3

From Terminal this works just fine and returns what is expected:

/Users/me/Desktop/Clients/IM/apps/node_modules/.bin/mjml newslettercode.html

This also works just fine from Terminal

node node_modules/.bin/mjml newslettercode.html

This also works just fine from Terminal

node_modules/.bin/mjml newslettercode.html

Im running MAMP & domain as my development.

From my .php file in my browser i get exec() error 127 and no output.

This test code:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

define('ROOT_DIR', realpath(__DIR__.'/..'));

$file =  ROOT_DIR.'/apps/node_modules/.bin/mjml newslettercode.html';

exec($file, $output, $responseCode);

print_r ($file);

echo "<pre>";
print_r($output);
echo "</pre>";

echo "<pre>";
print_r($responseCode);
echo "</pre>";

Returns this:

/Users/me/Desktop/Clients/IM/apps/node_modules/.bin/mjml newslettercode.html

Array
(
)

127

Im assuming that Node is not running on My MAMP Host? im not sure.. any help would be appreciated.

5
  • Make sure That you using the direct path of the application , it sounds like php can't find the application. Commented Dec 6, 2018 at 17:56
  • 1
    try exec('/usr/bin/node node_modules/.bin/mjml newslettercode.html') Commented Dec 6, 2018 at 17:57
  • @HamzaNig i tried both and didnt work. Sidenote... i looked in 'usr/bin' and i dont see any "node" Commented Dec 6, 2018 at 18:13
  • @HamzaNig changed it to '/usr/local/bin/node' and it worked... thanks for pointing me in the right direction... now wondering how that will translate/work when pushing to production. Commented Dec 6, 2018 at 18:15
  • yeah great then you welcome brother , usually /usr/bin/node is the default path but sames are changed on your platform nice try good Job , i will add it as an answer to help people directly without searching on comment Commented Dec 7, 2018 at 8:29

1 Answer 1

2

The problem Was in path of the aplication php can't find the application by using just node /../..php try to use the command bellow should make the work :

@HamzaNig : /usr/bin/node mostly is the default path

@Joe : /usr/local/bin/node is the default path on his platform

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.