1

When running a Meteor + ReactJs app on the production server, I want to disable all the console logs and error statements from popping up.

Is there any way to do so? Something like setting a variable in the settings.json file or something like that?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
squareRoot
  • 77
  • 9
  • 1
    Possible duplicate of [How to quickly and conveniently disable all console.log statements in my code?](https://stackoverflow.com/questions/1215392/how-to-quickly-and-conveniently-disable-all-console-log-statements-in-my-code) – lependu Nov 18 '18 at 13:02
  • If you use any JS bundle, you should check for drop console.log plugin. For webpack, check this [thread](https://stackoverflow.com/questions/41040266/remove-console-logs-with-webpack-uglify). I found other node modules for other JS bundles like gulp. – Mir Nov 18 '18 at 14:16

1 Answers1

0

The easiest way is to redefine your console.log and console.error to empty functions

console.log = (msg) => { };
console.error = (msg) => { };

console.log("nothing appears!");
console.error("neither here!");
mhv
  • 73
  • 6