hello guys I am new to node js
i am trying to run following code
var express = require('express'),
app = express(),
cons = require('consolidate'); // Templating library adapter for Express
app.engine('html', cons.swig);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.get('/', function(req, res){
res.render('hello', { name : 'World' });
});
app.get('*', function(req, res){
res.send('Page Not Found', 404);
});
app.listen(8080);
console.log('Express server started on port 8080');
then error comes
TypeError: string is not a function at EventEmitter.render (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\application.js:569:12) at ServerResponse.render (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\response.js:961:7) at C:\Users\YAm\Desktop\mongodb\work\test_coso.js:10:6 at Layer.handle [as handle_request] (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\layer.js:95:5) at C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:277:22 at Function.process_params (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:330:12) at next (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:271:10) at expressInit (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\middleware\init.js:33:5) at Layer.handle [as handle_request] (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:312:13) at C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:280:7 at Function.process_params (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:330:12) at next (C:\Users\YAm\Desktop\mongodb\work\node_modules\express\lib\router\index.js:271:10)
res.render()
is being served by the Express implementation which expectsres.render(view [, locals] [, callback])
. My guess it that either your templating/view engine is not properly installed or initialized or you are not using it correctly. – jfriend00