Reputation: 349
I have a use case where i need to run a node module in php script and display it's output back on the page. Here's the steps I followed:
npm install -g md2gslides
exec()
for running the module exec('node_modules/md2gslides/bin//md2gslides.js --version 2>&1', $output);
However, it runs in ubuntu's terminal without issues.
What is wrong here?
Upvotes: 0
Views: 566
Reputation: 349
The error not because of php but because of the path.join()
in line 33 of md2gslides.js
const STORED_CREDENTIALS_PATH = path.join(USER_HOME, '.md2googleslides', 'credentials.json');
It tries to find the credentials.json in users home directory. But I think it's unable to.
So I moved the file to node_modules/md2gslides/bin
and modified path.join()
as
path.join(__dirname, '.md2googleslides', 'credentials.json')
This solved the issue.
Upvotes: 1