Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Less Windows Node.js Hanging

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"
like image 839
Matt Avatar asked Jan 27 '12 06:01

Matt


People also ask

Why is NodeJS so slow?

Node. js programs can be slow due to a CPU/IO-bound operation, such as a database query or slow API call. For most Node. js applications, data fetching is done via an API request and a response is returned.

Is Windows good for NodeJS?

Using Node. js directly on Windows is great for learning and experimenting with what you can do. Once you are ready to build production-ready web apps, which are typically deployed to a Linux-based server, we recommend using Windows Subsystem for Linux version 2 (WSL 2) for developing Node. js web apps.

When NodeJS is not recommended?

js receives a CPU-bound task: Whenever a heavy request comes to the event loop, Node. js would set all the CPU available to process it first, and then answer other requests queued. That results in slow processing and overall delay in the event loop, which is why Node. js is not recommended for heavy computation.

Is Bun faster than node?

One of the main selling points of Bun is its high speed. The runtime is a few times faster than both Node and Deno, mainly because it uses the JavascriptCore instead of the V8 engine. It is also written in a low-level programming language that uses manual memory management.


2 Answers

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>
like image 166
timaschew Avatar answered Sep 24 '22 13:09

timaschew


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$"
like image 38
Onshop Avatar answered Sep 22 '22 13:09

Onshop