BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.
http://www.jsviews.com
MIT License
2.68k stars 340 forks source link

Error: callback function required #282

Closed daslicht closed 8 years ago

daslicht commented 8 years ago

Hi, when I add the viewengine to express like the following:

app.engine('html', jsrender.__express);
app.set('view engine', 'html');

I get this error:

Error: callback function required
    at EventEmitter.engine (/Users/daslicht/DEV/jsviews/isomorphic/node_modules/express/lib/application.js:294:11)
    at Object.<anonymous> (/Users/daslicht/DEV/jsviews/isomorphic/app.js:25:5)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3

It is teh same code as in your example, what am I missing please?

daslicht commented 8 years ago

Here is the generated package json:

{
  "name": "isomorphic",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.14.1",
    "express": "^4.13.3",
    "jquery": "^2.1.4",
    "jsrender": "0.0.3",
    "serve-favicon": "^2.3.0"
  }
}

My node version:

node -v
v4.2.2

nvm --version
0.29.0

npm --version
2.14.7

I installed all dependencies like the following:

npm init
npm install body-parser --save
npm install jsrender --save 
...
daslicht commented 8 years ago

with the latest jsrender i no longer have that issue

BorisMoore commented 8 years ago

Unfortunately there is a bug in npm prior to 3.4.1 that installs a very very old version rather than the latest. See https://github.com/BorisMoore/jsrender/issues/278. So until now you will have been missing a huge number of JsRender features.

iguerrero84 commented 8 years ago

This error happended to me and i realized that it was missing a "require" for ('consolidate')

BorisMoore commented 8 years ago

@iguerrero84 - I didn't understand you there. Were you getting the JsRender version 0.0.3 as a result of having a version of npm prior to 3.4.1? In that case you need to update npm then re-install JsRender.

Or was your error with a recent version of JsRender? (In which case can you explain where the require was missing - I don't follow.)