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 trial

JavaScript Express Basics Deeper into Routing with Express POST Requests

Peter Eriksson
Peter Eriksson
12,187 Points

Trying to run the program. Downloaded the files. "Error: Cannot find module 'pug'"

I'm pretty fresh on this subject so I'm quite confused on the error message. Anyone now the issue?

1 Answer

Check your package.json file. If pug isn't listed in the 'dependencies' or 'devDependencies' objects you can install it with:

npm install pug

if it is listed maybe you forgot to install the project dependencies when you downloaded the files. If your project doesn't have a node_modules directory within it this is probably the case. You can install the needed dependencies with:

npm install

The dependencies part of package.json should look similar to this:

"dependencies": {
    "body-parser": "^1.17.1",
    "cookie-parser": "^1.4.3",
    "express": "^4.15.2",
    "pug": "^2.0.0-rc.1"
  }
Frank Kynard
Frank Kynard
6,958 Points

Thank you so much this work for me as well. Its been a day and a half working on this!!!!