nodejs require() fails when called from php script (linux)

194
January 31, 2018, at 7:08 PM

I have this script, minimathjax.js

console.log('toto');
var mjAPI = require("/home/pi/node_modules/MathJax-node/lib/mj-page.js");
console.log('titi');
....

It works fine when called from console ('node minimathjax.js' in its folder).

But when I try to call it from a php file :

$string = 'node /home/pi/node_modules/MathJax-node/minimathjax.js';
$res = exec ($string);
echo $res;

I just get 'toto', indicating that the require() fails.

How can I solve that ? It worked when I wrote it in Windows, and fails on linux (raspbian).
Is it related with permissions ?

Rent Charter Buses Company
READ ALSO
How to use authenticate a user for google sheets api on a remote server using Node.js?

How to use authenticate a user for google sheets api on a remote server using Node.js?

I am working with Google sheets and nodejs and I am able to authorize a user locally and get auth data using cmd using this tutorial https://developers

222
MongoDB replica set on windows facing some basic issues

MongoDB replica set on windows facing some basic issues

I am on Windows 10 EnvironmentI would like to Implement Replica Set on MongoDB

177
Get request status best practice

Get request status best practice

In my Nodejs backend, I used to add a boolean in my response to check if everything went good:

272
wt vs. Meteor.js

wt vs. Meteor.js

Does anybody have a good idea about wt framework, specially in comparison to other popular frameworks, like say Meteorjs

263