Less Windows Node.js Hanging
Asked Answered
D

3

4

I have been trying to setup Symfony2 on Windows so that I can use assetic with less.

I have installed node.js for Windows (0.6.8). Then I have run npm install less --global and found less in C:\Users\Matt\AppData\Roaming\npm\node_modules

As far as my Symfony setup, I have the master branch of Assetic (due to a bug I read about in 1.0.2), but the standard v1.0.1 of AsseticBundle

After some work, I was able to get an example less file to render via: http://localhost/app_dev.php/css/compiled-main_part_1_boilerplate_1.css

Then I switched a .less file that @imports other .less files (in the same subdirectory). Whenever I try to go to that page on my local server (using this less configuration) it hangs and I can see a command process and a node.exe process both running.

The command is trying to run a script in node.js which exists in my temporary directory. I can run that file through node.js in a command prompt fine, but I cannot get it to load using Symfony/Assetic.

Is there anyway to use node.js, less, and assetic on Windows?

Here is my relevant config file sections:

# Assetic Configuration
assetic:
    debug:           %kernel.debug%
    use_controller: false
    bundles: [FeedStreamMainBundle]
    # java: /usr/bin/java
    filters:
        cssrewrite: ~
        less:
            node: %assetic_node%
            node_paths: [%assetic_less_path%]
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
        yui_css:
            jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar
        # closure:
        #     jar: %kernel.root_dir%/java/compiler.jar

dev config override:

assetic:
    use_controller: true

in parameters.ini:

assetic_node="C:\\Program Files (x86)\\nodejs\\node"
assetic_less_path="C:\\Users\\Matt\\AppData\\Roaming\\npm\\node_modules"
Desk answered 27/1, 2012 at 6:39 Comment(1)
I changed the parameters to this: assetic_less_path="C:\\web_workspace\\lib\\node_modules" and I can get the page localhost/app_dev.php/css/… to load once again. Then I try to load that page again or a normal page and it just hangs again...Desk
D
0

Since no one really has any answers, I can only assume there are very few Windows developers using LESS and node.js in Symfony2.

My solution was to use lessphp which worked fine once I got it into the autoloader.

Desk answered 15/2, 2012 at 19:43 Comment(3)
I haven't looked into this in a year. But probably not. Open an issue on it maybe?Desk
I opened one here github.com/symfony/AsseticBundle/issues/155 if you can, vote itHartle
There's a bug in Assetic. I have opened a pull request to fix it github.com/kriswallsmith/assetic/pull/411 . The reason was that the env variable SystemRoot has not been passed to the node.js process.Greenebaum
T
4

yes, use lessphp (server side)

Symfony2.1. How to integrate assetic lessphp filter. Add the following

package to your composer.json:

"require": {
    ...
    "leafo/lessphp": "dev-master",
    ...
}

Run php composer.phar update

and update your config.yml

#...
assetic:
    #...
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"

or use the less.js (client side)

<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>
Taxi answered 31/10, 2012 at 16:47 Comment(0)
U
3

I used the following and this works for me. NOTE that it is 'node.exe' and not just node.

node: "C:\\Program Files (x86)\\nodejs\\node.exe"
node_paths: ["C:\\Users\\Ben\AppData\\Roaming\\npm\\node_modules"] 
apply_to:   "\.less$"
Ultan answered 21/6, 2013 at 12:3 Comment(1)
Since there is a bug in new implementation of less in lessphp, this solution workedTutelary
D
0

Since no one really has any answers, I can only assume there are very few Windows developers using LESS and node.js in Symfony2.

My solution was to use lessphp which worked fine once I got it into the autoloader.

Desk answered 15/2, 2012 at 19:43 Comment(3)
I haven't looked into this in a year. But probably not. Open an issue on it maybe?Desk
I opened one here github.com/symfony/AsseticBundle/issues/155 if you can, vote itHartle
There's a bug in Assetic. I have opened a pull request to fix it github.com/kriswallsmith/assetic/pull/411 . The reason was that the env variable SystemRoot has not been passed to the node.js process.Greenebaum

© 2022 - 2024 — McMap. All rights reserved.