Run bower from root user, it's possible? How?

非 Y 不嫁゛ 提交于 2019-11-28 16:19:22

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:

  1. add --allow-root to command
  2. set global bower config that will allow running bower as root

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 are encountering this issue on Docker containers just add this line in your Dockerfile:

RUN echo '{ "allow_root": true }' > /root/.bowerrc
keisar

This might be stupid but for me bower install --allow-root did not work but bower --allow-root install did, using grunt-bower-install version 1.6.0

This was on a docker running with root user, perhaps will save someone some time :)

Faced similar issue when installing swagger-editor. Changed the following line in package.json from

"bower-install": "bower install"

to

"bower-install": "bower install --allow-root"

This works for me (add -u parameter on docker run)

bash docker run -it -v ${PWD}:/www -w /www -u node node ./node_modules/bower/bin/bower install

For My case it is in Pom.xml where i have added as an argument as below:

<executable>bower</executable>
 <arguments>
 <argument>install</argument>
  <argument>--allow-root</argument>
 </arguments>

If need to avoid this --allow--root parameter we can do a compile out of root user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!