如何将php配置文件传递给Node.js?

My php config file looks like:

define('hostname_con1', 'localhost');
define('database_con1', 'mydatabase');
define('username_con1', 'user');
define('password_con1', 'password');

What would be the "smart" method to use that in my nodejs application to avoid to define database parameters again in my nodejs application ?

var client = mysql.createConnection({
    host     : 'localhost',
    user     : 'user',
    password : 'password',
    database : 'mydatabase',
    charset: 'utf8', 
    insecureAuth: true,
});

I want to have 1 single config file for all (php and nodejs)

regards

Store the configuration in a format that can be parsed by both languages and is not PHP specific, e.g. JSON, YAML, INI, whathaveyou.

You will need to use a common data format that both Node and PHP can process.

Easiest would be to store your data as JSON, and use json_decode() in PHP and appropriate code in node to parse it. But you can use any other format (such as yaml, ini, etc) for which there are both PHP and JavaScript parsers.