Symfony2 Assetic: Path to node executable could not be resolved
Solution 1
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
Solution 2
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
Solution 3
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 )
Solution 4
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
.
Solution 5
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
Serhii Smirnov
An experienced remote developer. A problem solver. Passionate about improving or building a great product. Diligent, focused on quality, and sweat the details of my work. Backend developer. PHP Expert with 12 years of experience, Symfony developer with 5 years of experience.
Updated on June 17, 2022Comments
-
Serhii Smirnov almost 2 years
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.
-
kyrgyz_jigit over 7 yearsyour 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 files
-
Peter over 7 yearsQuick and dirty, but it got me going again. Thanks!
-
Joseph Astrahan about 7 yearsTo elaborate I changed the node to /usr/bin/nodejs and it worked for me.
-
pmiranda over 5 yearsIn my situation it was `/usr/bin/node'