Reputation: 31
I created a test code for using node(0.5.7), express(2.3.9) and ejs(1.0). Here is the sample code
core.js
var express = require('express');
var http = require('http');
var ejs = require('ejs');
var app = express.createServer();
app.set('views', __dirname + '/views');
app.set( "view engine", "ejs" );
app.get('/', function(req, res) {
res.render('index');
});
app.listen(8000);
console.log('Listening 8000');
Mentioned is the path where the ejs file lies --> views/index.ejs
I am getting the error "TypeError: Object # has no method 'compile'"
Can you please help me what solution would be the best applicable over here?
Upvotes: 1
Views: 2999
Reputation: 3908
Make sure you follow these instructions when using express to create the skeleton project particularly the portion where you use npm install
to install the dependencies.
Create the app:
$ npm install -g express
$ express /tmp/foo && cd /tmp/foo
Install dependencies:
$ npm install
Start the server:
$ node app
Upvotes: 0
Reputation: 68373
What might be wrong is that express version 2.3.9 is not comaptible with node version 0.5.7 (which is an unstable branch for 0.6.x series), therefore you should try it with stable version of node from 0.4.x series. From express docs:
Express 1.x is compatible with node 0.2.x and connect < 1.0.
Express 2.x is compatible with node 0.4.x and connect 1.x
Express 3.x (master branch) is compatible with node 0.6.x and connect 2.x
Upvotes: 1