Error: Cannot find module 'pug' Error: Cannot find module 'pug' node.js node.js

Error: Cannot find module 'pug'


Try to add this line

app.engine('pug', require('pug').__express)

before

app.set('views', path.join(__dirname, 'views'));app.set('view engine', 'pug');

This solved the same problem for me!


When there is a mismatch of module installation between Global and Local you will encounter this issue even if you have installed it all the modules. I would suggest you to install everything local to the project by including the dependency in the package.json

npm install --save express jade pug


The simplest fix is to install pug as a development dependency: npm i -D pug