从root用户运行凉亭,有可能吗? 怎么样?
我有一个本地开发服务器,在这里我testing了很多东西,现在我正在玩鲍尔来pipe理我的Symfony2项目中的库依赖项。 在安装NodeJS(v0.10.31)和bower(1.3.9)之后,我尝试以root身份从控制台运行命令sp:bower:install ,它属于Symfony2 SpBowerBundle: 
 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 
 我知道添加--allow-root工程,因为我直接从bash进行testing,但显然不允许从捆绑命令行。 现在,是以root身份运行bower的唯一方法是添加--allow-root还是以另一种方式存在? 
下面的答案是为symfony框架的捆绑, 但如果你从谷歌使用短语“ 鲍尔根 ” 来到这里你有两个select来解决:
- 将–allow-root添加到命令
- 设置全局的bowerconfiguration,这将允许作为根运行凉亭
选项1:您可以通过键入以root身份运行bower:
 bower install --allow-root 
root允许通过设置–allow-root命令参数
选项2:使用全局设置,允许root,通过创build文件: /root/.bowerrc其中有以下configuration:
 { "allow_root": true } 
 如何在SpBowerBundle symfony包中做到这一点: 
 可能你没有在SpBowerBundleconfiguration中将sp_bower.allow_root设置为true 
在包configuration中,默认情况下你已经设置了这样的东西:
 allow_root: false # optional 
但你应该有:
 allow_root: true 
所以在app / config / config.yml中添加这个bundle config
 sp_bower: allow_root: false # optional 
软件包configuration参考(所有设置): https : //github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md
我通过更改目录权限解决了类似的问题:
 sudo chown -R $USER:$GROUP ~/.npm sudo chown -R $USER:$GROUP ~/.config 
如果您在Docker容器上遇到这个问题,只需在Dockerfile中添加以下代码:
 RUN echo '{ "allow_root": true }' > /root/.bowerrc 
 这可能是愚蠢的,但对我来说bower install --allow-root不起作用,但是bower --allow-root install没有,使用grunt-bower-install版本1.6.0 
这是在与root用户运行的docker工人,也许会省下一些时间:)
安装swagger-editor时遇到类似的问题。 将package.json中的以下行更改为
 "bower-install": "bower install" 
至
 "bower-install": "bower install --allow-root" 
这对我有用(在Docker上添加-u参数)
 bash docker run -it -v ${PWD}:/www -w /www -u node node ./node_modules/bower/bin/bower install 
对于我的情况是在Pom.xml中,我已经添加为一个参数如下:
 <executable>bower</executable> <arguments> <argument>install</argument> <argument>--allow-root</argument> </arguments> 
如果需要避免这个–allow – root参数,我们可以从root用户进行编译