Question

So I've got a project that uses Express.js and Jade. There are a few Jade snippets that I use to create HTML inside the Node.js app.

Example:

var jade = require('jade');

var jadeStr = jade.compile('<h1 class="#{ var.class }">var.heading</h1>');
var jadeObj = { class: "heading", heading: "Example heading text."};

var htmlString = jadeStr(jadeObj);
// use htmlString for a log or error message or whatever

Right now my package.json file includes both Express.js and Jade, I'd prefer to rely on Express to supply the Jade package, as I don't want to worry about keeping Express and Jade versions in-sync.

When I remove Jade from my package.json, it errors that it can't find the Jade library. Is there a way of getting the Jade library used by Express.js without including it separately in my package.json file?

Était-ce utile?

La solution

In express 3.4, jade is specified in devDependencies, which means it won't get installed when you run npm install express; you are required to install it yourself. However, since it's unlikely that express will break backwards compatibility with jade very often, there is no need to update it.

Autres conseils

You could move jade from devDependencies to dependencies in the express module package.json inside node_modules.

enter image description here

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top