Symfony2 Assetic: Path to node executable could not be resolved
Asked Answered
P

6

8

When running app/console assetic:dump, I am getting:

Path to node executable could not be resolved

What does it mean and how to fix this?

When trying to browse project via app_dev.php, I am getting an HTTP 500 errors when browser tries to download css and js files.

Piloting answered 5/3, 2014 at 12:45 Comment(1)
Are you using any assetic filters which need node.js like uglify?Ronel
L
20

First make sure you have node installed and find the path to node. You can usually find this by using which node which will return something like /usr/local/bin/node. If it returns something like /usr/bin/which: no node in ... you need to install node.

Next configure symfony. Open your config.yml (./app/config/config.yml) and the path to node to you assetic config, i.e.:

# app/config/config.yml
assetic:
    node: /usr/local/bin/node
Lipread answered 15/4, 2014 at 10:40 Comment(2)
To elaborate I changed the node to /usr/bin/nodejs and it worked for me.Scurf
In my situation it was `/usr/bin/node'Penchant
Z
5

This worked for me

sudo apt-get remove nodejs
sudo apt-get remove npm

sudo curl -sL https://deb.nodesource.com/setup | sudo bash -

sudo apt-get install nodejs
Zyrian answered 3/9, 2014 at 16:48 Comment(0)
C
4

I add the exact same error while doing

php app/console assetic:dump --env=prod

On Ubuntu there is a confusion between node and nodejs binary. To solve this you need to install node binary. In my case the binary was nodejs, so it didn't work.

On Ubuntu the command which node will tell you if node is instaled. Try which node and if it doesn't work try which nodejs.

So to be sure there is no confusion I did :

    sudo apt-get remove nodejs
    curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
    sudo apt-get install -y nodejs

Check on node website for the correct url in the curl command. You might want node 5.X.

Now when you do

which node
/usr/bin/node

You have the correct binary name (node instead of nodejs).

After this it should work. If not check the node path in config.yml (check that there is no other declaration in config_prod and config_dev )

Counterpoise answered 7/1, 2016 at 14:37 Comment(0)
F
3

I've found that even if you specify /usr/bin/node in your config.yml you might still find assetic is trying to use /usr/local/bin/node.

The quick and dirty way to fix this is:

ln -sf /usr/bin/node /usr/local/bin/node

If you are in doubt, temporarily edit vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php

Edit near line 136:

        if (127 === $code) {
            throw new \RuntimeException('Path to node executable could not be resolved.');
        } 

->

        if (127 === $code) {
            throw new \RuntimeException('Path to node executable could not be resolved.' . $this->nodeBin);
        }

This will tell you where assetic expects node to be next time assetic fails.

I found in my set up assetic was configured to look to /usr/local/bin in dev mode but /usr/bin in prod mode. So it's worth checking config.yml, config_dev.yml and config_prod.yml.

Faythe answered 27/9, 2016 at 0:23 Comment(1)
Quick and dirty, but it got me going again. Thanks!Instigate
P
1

Are you using some filters like uglify ?

If this is the case, Assetic raises this error because the process exists with code 127, which means the node executable was unable to run.

Check the path in your config.yml :

# app/config/config.yml
assetic:
    filters:
        uglifyjs2:
            bin: /path/to/uglifyjs

And make sure it is executable :

chmod +x /path/to/uglifyjs
Pastorship answered 5/3, 2014 at 13:55 Comment(1)
your answer is work for me, but it need some additional corrections. We have to learn path to uglifyjs and uglifycss files by typing "which uglifycss" "which uglifyjs" and write it config_dev.yml and config.yml filesEnsor
R
0

Just make a composer update (php composer.phar update) then try dumping your assets. It may not work the first time, so update composer again.

Rotator answered 27/3, 2014 at 14:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.