I have a local development server where I test a lot of things, now I'm playing with bower to manage the libraries' dependencies in my Symfony2 project. After getting NodeJS (v0.10.31) installed and bower (1.3.9), I tried to run the command sp:bower:install
which belongs to Symfony2 SpBowerBundle from console as root
:
Symfony > sp:bower:install Installing bower dependencies for "TemplateBundle" into "/var/www/html/tanane/src/Tanane/TemplateBundle/Resources/config/bower/../../public/components" bower ESUDO Cannot be run with sudo Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs. http://www.joyent.com/blog/installing-node-and-npm https://gist.github.com/isaacs/579814 You can however run a command with sudo using --allow-root option
I know that adding --allow-root
works since I tested directly from bash but it apparently isn't allowed from the bundle command line. Now, is the only way to run bower as root
to add --allow-root
or does it exist another way ?
In almost all cases, it's more appropriate to use Browserify and npm over Bower. It is simply a better packaging solution for front-end apps than Bower is. At Spotify, we use npm to package entire web modules (html, css, js) and it works very well.
A clear and concise description of what the bug is. The npm install runs as root in the container, and since npm runs package-defined scripts, it has a protective mechanism to avoid running them as root, it drops its privileges to "nobody".
You can also create a bower. json file and define multiple packages name with or without version. Navigate to your project folder directory and run the command “bower install”. It will download and install all the packages in your bower_components folder.
below answer is for symfony framework's bundle, but if you come here from google using phrase "bower root" you have two options to solve that:
Option 1: you can run bower as root by typing:
bower install --allow-root
root is allowed by setting --allow-root command parameter
Option 2: is using global setting that allows root, by creating file: /root/.bowerrc which have inside following configuration:
{ "allow_root": true }
how to do this in SpBowerBundle symfony bundle:
probably you haven't set sp_bower.allow_root to true in SpBowerBundle config
in bundle config, by default you have set something like this:
allow_root: false # optional
but you should have:
allow_root: true
so in app/config/config.yml add this bundle config
sp_bower: allow_root: false # optional
bundle config reference (all settings): https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md
I fixed a similar problem by changing the directory permissions:
sudo chown -R $USER:$GROUP ~/.npm sudo chown -R $USER:$GROUP ~/.config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With