should i install morgan as a normal dependency or as devDependency since I'm not gonna use the logging in production mode anyway:
if (config.NODE_ENV !== 'production') {
app.use(morgan('dev', { stream: { write: message => logger.http(message) } }));
}
Assuming that
config.NODE_ENVmatches theprocess.env.NODE_ENVand that you installed vianpm install --productionor similar, then you don't need to includemorganin yourdependenciesand can just have it indevDependencies. You should move therequireorimportinside the if statement to prevent errors. When you callrequireorimportis when it tries to load fromnode_modulesor the module cache if it was already loaded.That said, I would personally include it in the
dependenciesand disable logging via a config setting in case I wanted to enable logging in my production environment to debug something.