Since you were creating the winston variable in the original code as const winston it wasn't able to add transports and other options in the following lines. The proposed solution moves the similar code into a module but assigns winston variable into var winston.