I've tried using a php code embedded in the main.js file but it does not work.
php is executed by the server and js by the browser. It can't work
You need to find the php line which loads your main.js. It should use the wp_enqueue_script function (hopefully !)