4

I've googled this and read just about all the threads I come over here in the forum, but still I can't get this to work.

I'm trying to make dust.js work with node.js

test.js:

var dust = require('dust');

Running it:

$ node test

Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
  at Function.Object.defineProperty.get (module.js:388:11)
  at Object.<anonymous> (/usr/local/lib/node_modules/dust/lib/server.js:6:8)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/usr/local/lib/node_modules/dust/lib/dust.js:511:7)
  at Module._compile (module.js:456:26)

$ node -v
v0.10.5

I installed dust like it' supposed to be installed:

$ npm install -g dust
npm http GET https://registry.npmjs.org/dust
npm http 200 https://registry.npmjs.org/dust
npm http GET https://registry.npmjs.org/dust/-/dust-0.3.0.tgz
npm http 200 https://registry.npmjs.org/dust/-/dust-0.3.0.tgz
dust@0.3.0 /usr/local/lib/node_modules/dust

I've tried setting the NODE_PATH:

export NODE_PATH="/usr/local/lib/node_modules"

or

export NODE_PATH="/usr/local/lib/node"

Still nothing works..

4

2 回答 2

7

The problem is that dust is not compatible with your node version. In the 0.6 version, node removed the require.paths method and dust repo is not being maintained anymore, so it just works with node 0.4.

Try the LinkedIn version wich has a lot of new features and is fully compatible with the new versions of node.

http://linkedin.github.io/dustjs/

于 2013-05-02T14:34:13.443 回答
0

try something like this:

var dust = require('dustjs-helpers');

var compiled = dust.compile("Hello {name}!", "intro");

dust.loadSource(compiled);

dust.render("intro", {
    name: "Márcio"
}, function(err, out) {
    console.log(out);
});
于 2014-09-11T17:55:36.530 回答