I have some code error due to upgrade in Magento 2 but my goal is to minify js. Till now I know that we can not minify js without correcting error of the code in magento but I want to know some trick some realy awesome trick to minify js even I have some issue in the code.
Go to admin panel Stores -> Configuration -> Advanced -> Developer . You will find option to enable js minification, choose it to be Yes (This option will be visible only if your developer mode is enabled.) . In your Magento 2 ssh console run the below command to set production mode if it is not set, because minification works only in production mode:
bin/magento deploy:mode:set production --skip-compilation
Note: --skip-compilation command is not mandatory, use it if you want skip compilation, i would recommend you to not skip it. Then run the below commands:
bin/magento cache:clean bin/magento setup:upgrade bin/magento setup:static-content:deploy
Navigate to Admin panel > Stores > Configuration > Advanced > Developer
When complete, click Save Config.
If the above solution is not working for you due to some bugs or errors, I would try this gulp solution
Although, I would strongly recommend fixing the error.