Reputation: 6158
I've been very frustrated with the "Let's build twitter" node app at Chapter 2 in the O'Reilly book "Node.js Up And Running".
I've never used EJS and don't even know what extension to put for EJS files. Plus, I can't get my app working getting these various errors:
It's even more frustrating since it's only the Chapter 2 and I'm wondering if it wouldn't be preferable to switch to another material...
Upvotes: 5
Views: 6134
Reputation: 1012
Install express@4 in the current project directory, it solved my problem!
Upvotes: 1
Reputation: 125
I have installed express@4 and resolved issue. if we write any code out side the editor and it will shows that error.
Regards, Ningappa
Upvotes: -1
Reputation: 99
O'Reilly Book Node.js Up and Running - Part 1 => Chapter 2 Doing Interesting Things => Let's Build Twitter (working code for Express 3.0 and ejs embedded JavaScript for node renderer without partials) download source: https://github.com/thinkphp/express-tweets
Upvotes: 0
Reputation: 2108
Support for EJS has been removed from Express v. 3. I've built another example using Express 3 and Jade templates:
https://github.com/nosolopau/node-up-and-running-chirpie-express-3
Upvotes: 2
Reputation: 1
I was also frustrated so I built a working example - available here for download:
https://github.com/iotaweb/node-up-and-running-chirpie
Upvotes: 0
Reputation: 6158
If you too have been frustrated with the "Let's build twitter" programming tutorial at the Chapter 2 in the O'Reilly Up and running book, here is the complement to make this "app" work.
Pre-requisites:
npm install [email protected]
npm install ejs
. The meat:
views
and partials
should have the extension .ejsapp.render()
function
You have two ways to do it: (1) You set EJS as the default template engine and then just tell express to render your file
app.set('view engine', 'ejs');
res.render('index', ...)
(2) You just tell to the app.render()
function to use EJS, express will take care of it
res.render('index.ejs', ...)
If at that point it doesn't work or it's still not clear, nothing is better than looking at working code. Fork or download the app here.
Hope it helps other readers.
Upvotes: 10