I faced the same problem. I ran the below from the directory where my node js file was
npm install --save morgan
Using above command adds the dependency to your package.json.
Once package added, logger can now be used as
logger = require('morgan');
app.use(logger('dev'));