Hi jorgb
None of the above suggestions work and they are for a different problem.
If you set mode to default, and then set mode to production it will compile fine.
Hope that helps. took me an age to suss that one out. Still don't know the cause. its obviously a magento bug but doesn't occur for everyone.
Best Regards
David
@davidthurston Lol thanks that indeed fixed the problem!
Since Magento 2.2.8 and 2.3.1, this method does not work anymore. Instead there is a special argument for the setup:config:set command:
bin/magento setup:config:set --enable-debug-logging=true
Then clear the config cache so that the change takes effect:
bin/magento cache:clean config
By default, Magento writes to the debug log (<install_directory>/var/log/debug.log) when it is in default or develop mode, but not when it is in production mode. Use the bin/magento setup:config:set --enable-debug-logging=true | false command to change the default value.
As of Magento 2.3.1, you can no longer use the bin/magento config:set dev/debug/debug_logging 0 | 1 command to enable or disable debug logging for current mode.
Source: https://devdocs.magento.com/guides/v2.3/config-guide/cli/logging.html