17

I have a fresh virtualenv environment and have got the latest django-pipleline.

The JS compression with Closure works perfect, but CSS compression with Yuglify fails, due a node error:

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.closure.ClosureCompressor'
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

When I try to collect the static:

./manage.py collectstatic

It says:

pipeline.compressors.CompressorError: /usr/bin/env: node: No such file or directory

But I have clearly installed yuglify even as global:

sudo npm -g install yuglify

/usr/local/bin/yuglify -> /usr/local/lib/node_modules/yuglify/bin/yuglify
yuglify@0.1.2 /usr/local/lib/node_modules/yuglify 
├── uglify-js@1.3.4
├── ycssmin@1.0.1
└── nopt@2.1.1

Trying to set the biney in settings doesn't help either:

PIPELINE_YUGLIFY_BINARY = '/usr/local/bin/yuglify'

I still get the same error. Why now such problems with npm? Is there something I have to setup additionally?

Alternatively is there a way to install yuglify with pip?

Many Thanks,

Houman
  • 64,245
  • 87
  • 278
  • 460
  • Can you try to run this : heroku run /usr/bin/env node – cyberdelia Jan 28 '13 at 18:24
  • 1
    Thanks for your response. I finally found it. It is an issue with `npm` and how it installs the yuglify package. It is not pretty. You better mention that in the documentation. ;) See my answer. – Houman Jan 28 '13 at 18:32
  • When I run heroku run /usr/bin/env node, it starts node terminal. How do I fix it? How do I run Hooman's solution on heroku? – Pratik Poddar Oct 06 '14 at 18:09

2 Answers2

25

After 3 hours of suffering, I have found the solution.

This is happening because of a misnaming error, if you install from a package manager (npm) your bin may be called nodejs so you just need to symlink it like this:

ln -s /usr/bin/nodejs /usr/bin/node

Now it is working. This didn't happen with the older version, its is something new. But at least it is working again. I hope this helps someone else out there. :)

Houman
  • 64,245
  • 87
  • 278
  • 460
  • Additionally for me, `which node` pointed at `/usr/sbin/node`, not `/usr/bin/node` from the above soft link. Removing the `sbin` version of node brought the yuglify compressor back online. – Craig Labenz Mar 09 '15 at 05:13
  • 1
    Also note that you must install yugliy with the `-g` as you specified above - `sudo npm -g install yuglify`. Without this the binary will not be linked to `/bin`. – Rebs Dec 15 '15 at 02:55
2

In my case both uglify-js and cssmin were somehow not installed.

So I have re-installed them again by using following command and then it starts working again.

sudo npm install -g cssmin uglify-js
user1012513
  • 2,089
  • 17
  • 14