最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting an error when running the basic Express project - Stack Overflow

programmeradmin7浏览0评论

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?

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?

Share Improve this question edited Mar 18, 2012 at 17:32 JChristian asked Mar 17, 2012 at 22:26 JChristianJChristian 4,1705 gold badges30 silver badges34 bronze badges 3
  • 1 Seems like that it's a jade or express issue. Try to dive into the code... – Farid Nouri Neshat Commented Mar 18, 2012 at 4:38
  • I edited my response on what I found after digging into the code. – JChristian Commented Mar 18, 2012 at 17:24
  • Downloading from source and extracting worked for me. Thanks for pointing out the missing file. Must be a bug with NPM/Jade. – foobar Commented Mar 22, 2012 at 16:02
Add a comment  | 

5 Answers 5

Reset to default 11

cd to your express project folder and run "npm install", this will install all dependencies

For me, on windows, jade version 0.22.0 fixed the issue.

it probably has to do with the fact, that you installed express globally (-g), but the npm install -d was done locally. try to install them both globally, or as i would prefer, both locally:

sudo npm uninstall express -g
npm install express
npm install jade (or npm install -d)

Really make sure that all the module requires are correct. Javascript is very funny about telling you what is actually wrong. Try removing the jade template line and see what happens then.

I just found this problem with the error of jade module. Looks like the jade folder was doesn't created automaticly (some kind of bug). Now i resolved this with reinstall jade. After that the jade folder was automaticly created. use npm uninstall gulp-jade and then install gulp-jade again

发布评论

评论列表(0)

  1. 暂无评论