How can I pass parameters when calling a Node.js script from PHP exec()?

You can pass parameters as you would pass it to any other script.

node index.js param1 param2 paramN

You can access the arguments through process.argv

The process.argv property returns an array containing the command line arguments passed when the Node.js process was launched. The first element will be process.execPath. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command line arguments.

exec("node app.js --token=my-token --mesage=\"my message\" &", $output);

app.js

console.log(process.argv);

/* 
Output:

[ '/usr/local/bin/node',
  '/your/path/app.js',
  '--token=my-token',
  '--mesage=my message' ] 
*/

You can use minimist to parse the arguments for you:

const argv = require('minimist')(process.argv.slice(2));
console.log(argv);

/*
 Output

{
    _: [],
    token: 'my-token',
    mesage: 'my message'
} 
*/

console.log(argv.token) //my-token
console.log(argv.message) //my-message