Categories
express javascript node.js pug

Getting an error when running the basic Express project

I’m messing around with Node.js for the first time and decided to create a simple application using express. I followed the instructions from github in an empty directory like so:

npm install -g express
express
npm install -d
node app.js

When navigating to localhost:3000 I get the follow error:

Express
500 Error: Cannot find module './lib/jade'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (C:\dev\gravity_kata\node_modules\jade\index.js:4:5)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)

When looking under node_modules\jade\lib I see all of Jade’s library files, but no jade folder. So I created a folder under lib called jade and moved the library files there and now my default application works.

Now, seeing as I have nearly no experience with Node.js and Express I’m pretty sure I did something wrong. Does anybody have any idea what is going on here?

Edit:

I dove into the Jade code. Under Jade’s index.js file it requires lib\jade and looking under the lib folder, there was no jade.js file. Well, that is the problem, but why is the jade.js file missing? When pulling the Jade source from npm, there is a jade.js file under the lib directory. I copied the lib folder from the downloaded source into the Jade module for my project and it works fine now.

So for some reason, npm isn’t pulling down the jade.js file. The version in the packages.json file match the source i pulled down, 0.21.0. Anybody have an idea on why this happened?