Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Hernandez
13,437 PointsWhenever I install body-parser, pug is deleted. And whenever I install pug body-parser is deleted.
I have been having this problem with my project, I cannot install body-parser or pug without the other being deleted and my code becoming unable to run. I don't know if the javascript code will help but here it is
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false }));
app.set('view engine', 'pug')
app.get('/', (req, res) =>{
res.render("index");
});
app.get('/cards', (req, res) =>{
res.render('card', { prompt: "Who is buried under Grant's Tomb"});
});
app.get('/hello', (req, res) =>{
res.render('hello');
});
app.post('/hello', (req, res) =>{
res.render('hello', {name: req.body.username});
});
app.listen(3000, ()=> {
console.log('The application is running on port 3000')
});
Any help would be greatly appreciated
1 Answer
Daniel Hernandez
13,437 PointsThanks, that did it! I feel silly for not thinking of that sooner
Amelia Groen
6,144 PointsAmelia Groen
6,144 PointsHave you tried installing both as dev dependencies? Use the --save-dev flag instead of just --save. You may need to remove them both first before trying to reinstall.
Here's my package.json file, with everything working fine.