Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

symfony2.3 configure assetic with less

symfony2.3 configure assetic with less

Problem

I am using Symfony "2.3.*" and I attempt to make assetic less filter working. I do all of this in the "dev" environment.

When I issue the config:dump-reference assetic I get the following output:

assetic:
    debug:                %kernel.debug%
    use_controller:
        enabled:              %kernel.debug%
        profiler:             false
    read_from:            %kernel.root_dir%/../web
    write_to:             %assetic.read_from%
    java:                 /usr/bin/java
    node:                 /usr/bin/node
    node_paths:           []
    ruby:                 /usr/bin/ruby
    sass:                 /usr/bin/sass
    variables:
        # Prototype
        name:                 []
    bundles:
        # Defaults:
        - FrameworkBundle
        - SecurityBundle
        - TwigBundle
        - MonologBundle
        - SwiftmailerBundle
        - AsseticBundle
        - DoctrineBundle
        - SensioFrameworkExtraBundle
        - FOSUserBundle
        - JMSSerializerBundle
        - YuccaPrerenderBundle
        - WebProfilerBundle
        - SensioDistributionBundle
        - SensioGeneratorBundle
    assets:
        # Prototype
        name:
            inputs:               []
            filters:              []
            options:

                # Prototype
                name:                 []
    filters:
        # Prototype
        name:                 []
    twig:
        functions:

            # Prototype
            name:                 []

So, my config looks like :

assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:
      - PlastoriaGiftoFrontBundle
    #java: /usr/bin/java
    node: "/usr/bin/nodejs"
    node_paths: [ "/home/webadmin/websites/gifto/node_modules" ]
    filters:
        cssrewrite: ~
        less: ~
        closure:
            jar: %kernel.root_dir%/Resources/java/compiler.jar
        yui_css:
            jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar

To test that it works, I do open the Symfony Console and issue cache:clear Then I go to the cache dir (app/cache) and do rm -rf *. After I come back in Symfony console and launch these two commands:

assets:install
assetic:dump

And I am greeted with the following message :

Dumping all dev assets. Debug mode is on. 13:51:22 [file+] /home/webadmin/websites/gifto/app/../web/css/ac28136.css [Assetic\Exception\FilterException] An error occurred while running: '/usr/bin/nodejs' '/tmp/assetic_lessjHtxDR' Error Output: module.js:340 throw err; ^ Error: Cannot find module 'less' at Function.Module._resolveFilename (module.js:338:15) ... (truncated)

The configuration for the node binary is taken into account : An error occurred while running: '/usr/bin/nodejs'

By default, the value is /usr/bin/nodejs.

I can't figure out what's wrong. Did install "less" node module in the application using npm and when issuing npm ls, I can see it is properly installed.

I also launched nodejs in the application directory and did a require('less') and it worked without error.

What is the right way of configuring assetic with nodejs ?

Problem courtesy of: programaths

Solution

Found,

I entered in the server as root (Yes, I know, bad practice) then I su webadmin!

The trick is to really login as webadmin or su webadmin -l.

I tested and it was the issue.

Solution courtesy of: programaths

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

symfony2.3 configure assetic with less

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×