DustJS – Getting ‘Duster’ to work on OS X / Linux

This is going to be a short post on one of the issues I came across when I was trying to use LinkedIn DustJS on my Mac Book. I was trying out DustJS for one of the new projects I’m working on, and I came across ‘DusterJS’ (https://github.com/dmix/dusterjs/), which is a watcher that could monitor your .dust files and convert them on-the-fly to compiled dust templates. This is a life saver when it comes to developing dust templates, and kudos to the author for writing such a great tool.

DusterJS is based on Node, and it’s available in the NPM repos. So it was easy to install this on my Mac with just one command.

npm install -g dusterjs

Once installed, we can run DusterJS in the command line by running the command ‘duster’. However, when I tried this on the Mac, it failed with following error.

Yohan:bin Yohan$ duster
env: node\r: No such file or directory

After a quick Google, I found that this was because of the ‘Windows’ style line breaks in the /usr/local/lib/node_modules/dusterjs/bin/cli.js, which is the executable for duster. To fix this, there were different approaches, and below is what I used.

First off, I used the following command to convert line breaks.

cat cli.js | col -b >cli2.js

Then I backed up the original cli.js, and renamed the cli2.js as cli.js, and granted execute permissions on the new cli.js.

mv cli.js cli-old.js
mv cli2.js cli.js
chmod a+x cli.js

And gave it a spin,

Yohan:bin Yohan$ duster
Watches a directory tree and compiles templates when changed.
Usage: duster [options] input [input...] output

Voila, it works. I raised an issue in GitHub project page for this one so that this will be fixed in a future release (https://github.com/dmix/dusterjs/issues/15). On the interim, hope this helps if someone stumbles upon this situation.

UPDATE : The issue in DusterJS NPM Package has been fixed by the developer, I believe this is no longer be needed. It works out of the box now. Kudos to Lee Houghton for pushing this fix immediately. This is why I love open source 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *