Question

The problem:

  • I am using laravel 4 + basset for asset management (OSX).
  • i have added the twitter bootstrap to my composer as a dependency.
  • I want to compile the less files into a collection:

    Basset::collection('TwitterBootstrap', function($collection)
    {
        // Collection definition.
        $collection->add('../vendor/twbs/bootstrap/less/bootstrap.less');
    })->apply('Less');
    
  • I then try to build the collection:

    php artisan basset:build TwitterBootstrap
    
  • Which throws the error:

    [Assetic\Exception\FilterException]
      An error occurred while running:
      '/usr/local/bin/node' '/private/var/folders/f4/xjby77695pbcgfdjfclfdqd40000gn/T/assetic_less5y7dnh'
    
      Error Output:
    
      module.js:340
          throw err;
                ^
      Error: Cannot find module 'less'
          at Function.Module._resolveFilename (module.js:338:15)
          at Function.Module._load (module.js:280:25)
          at Module.require (module.js:364:17)
          at require (module.js:380:17)
          at Object.<anonymous> (/private/var/folders/f4/xjby77695pbcgfdjfclfdqd40000gn/T/assetic_less5y7dnh:1:74)
          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 Function.Module.runMain (module.js:497:10)
    

I have installed less globally - im unsure why this is throwing errors/what to fix (my path? a node config? an assetic config?)

Was it helpful?

Solution

I had the same problem and I solved it by installing less with npm :

npm install less

To use less globally, do not run "npm install less" at the root of your project. Instead add a symlink to the global one (/home/{user}/node_modules/less/) in your project :

ln -s /home/{user}/node_modules/less/ /path/to/project/node_modules/less
ln -s /home/{user}/node_modules/less/bin/lessc /path/to/project/node_modules/less/.bin/lessc

OTHER TIPS

How did you install less?

npm install less

Reference: https://npmjs.org/package/less

Edit... Just saw your footnote.

Another option would be to install lessPHP via composer and use LessphpFilter instead of LessFilter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top