Symfony Assetic Bundle Node resolving common install conflict when dumping assetic assets

A common Symfony issue with a new server deals with Assetic and Node working together.  You can run Symfony without either one, but if you’re a fan of Node and want to utilize everything you can like Assetic and LESS, it’s worth the extra 20 minutes or so struggling with the proper settings.  As you can see below, here’s the output from a recent shell on a dev server as I’m trying to dump my Assetic assets but to no avail.  Why?  Node couldn’t be found on the server.  Googling the solution and finding the right answer was a challenge.

The easiest way is to create a new symlink to where it actually is, in this case, “nodejs” was actually installed so the symlink had to point to the directory /user/local/bin/node   from the /user/bin/nodejs root version.  I find I have to do this and usually forget to, more frequently because some hosts just don’t allow LESS or even Composer sometimes for security reasons, I never rely on the fact that a server may not be able to leverage Assetic and Less fully.  But that’s what a dev server is also useful for, since you can set up things anyway you want, you can always just dump your Assetic assets there then upload those optimized and compressed assets to the staging or live site for further processing.  Not an ideal workflow, but useful either way since you could just have Symfony’s views just fallback on the uncompressed assets which you could also manually compress and minify, which is more work but at least you know it’s not a deal breaker.

As you can see from above, Assetic also wanted to compress the jquery library and that was the only error dumping the assets because there was an error in its path inside the config.yml file in the Assetics properties.  The example above is enough to give you an idea of how to make sure Assetic works properly — documentation about this is scant to say the least.


Aaron Belchamber has written 245 articles

Leave a Reply

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