so I've been trying to run an SMS script after the user submits a form. If I use
node send-sms.js
locally on my machine, it works. However, if I try to use
$sendSmsPath = "send-sms.js";
exec('/public_html/node_modules/node '.$sendSmsPath);
Nothing happens. No error, nothing. I tried using a relative path, as well as an absolute one. My folder scheme is as follows: public > other_folder > php > php_file.php AND public > node_modules
Any ideas are welcome, thanks
You are using the wrong path to Node.js. Try this:
<?php
$sendSmsPath = "send-sms.js";
exec('/c/Program Files/nodejs/node '.$sendSmsPath);
node_modules
is for the dependencies of your script, not the actual Node.js executable.
If you'd like to run your script on another machine make sure it has Node.js installed globally and you know the path of the executable (can be found with which node
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.