Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'pug' #113

Open
hakankaraduman opened this issue Sep 26, 2018 · 1 comment
Open

Cannot find module 'pug' #113

hakankaraduman opened this issue Sep 26, 2018 · 1 comment

Comments

@hakankaraduman
Copy link

Hi,

I have my webpack config as follows

`const path = require('path');

module.exports = (env) => {
return {
mode: env.mode,
entry: path.resolve('index.js'),
output: {
filename: 'bundle.js',
path: __dirname
},
target: 'node',
node: {
__dirname: true,
__filename: true
},
module: {
rules: [
{
test: /.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-env'],
plugins: ["@babel/plugin-transform-runtime"]
}
},
{
test: /.pug#/,
loader: 'pug-loader',
exclude: /node_modules/
}
]
}
}
}`

I have my express server like below:

app.get('/', (req, res) => { res.render('index', { title: 'DashMon Application', message: 'Sample App', content }) }); app.get('/info', (req, res) => { res.send(content); }); app.listen(port, () => { console.log(Listening on port ${port}); });

The problem is, webpack builds without error, and server runs without error.
When I go to the localhost, it gives error below

Error: Cannot find module 'pug'
at webpackEmptyContext (webpack:///./node_modules/express/lib_sync?:2:10)
at new View (webpack:///./node_modules/express/lib/view.js?:81:78)
at Function.render (webpack:///./node_modules/express/lib/application.js?:570:12)
at ServerResponse.render (webpack:///./node_modules/express/lib/response.js?:1008:7)
at eval (webpack:///./index.js?:84:9)
at Layer.handle [as handle_request] (webpack:///./node_modules/express/lib/router/layer.js?:95:5)
at next (webpack:///./node_modules/express/lib/router/route.js?:137:13)
at Route.dispatch (webpack:///./node_modules/express/lib/router/route.js?:112:3)
at Layer.handle [as handle_request] (webpack:///./node_modules/express/lib/router/layer.js?:95:5)
at eval (webpack:///./node_modules/express/lib/router/index.js?:281:22)

How do I solve this? Thanks

@ThisNameWasTaken
Copy link

Did you try npm install pug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants