从 root 用户运行 bower,这可能吗?如何? [英] Run bower from root user, it's possible? How?
问题描述
我有一个本地开发服务器,我在其中测试了很多东西,现在我正在使用 bower 来管理我的 Symfony2 项目中的库的依赖项.在安装 NodeJS (v0.10.31) 和 bower (1.3.9) 后,我尝试以 root
sp:bower:install>:
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
我知道添加 --allow-root
是有效的,因为我直接从 bash 进行了测试,但显然捆绑命令行不允许这样做.现在,以 root
身份运行 bower 以添加 --allow-root
的唯一方法还是以其他方式存在?
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 ?
推荐答案
下面的答案是针对 symfony 框架的 bundle,但如果您从 google 来到这里,使用短语bower root",您有两种选择来解决这个问题:
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:
- 在命令中添加 --allow-root
- 设置全局凉亭配置,将允许以 root 身份运行 Bower
选项 1:您可以通过键入以下内容以 root 身份运行 bower:
Option 1: you can run bower as root by typing:
bower install --allow-root
通过设置--allow-root命令参数允许root
root is allowed by setting --allow-root command parameter
选项 2: 使用允许 root 的全局设置,通过创建文件:/root/.bowerrc其中有以下配置:
Option 2: is using global setting that allows root, by creating file: /root/.bowerrc which have inside following configuration:
{ "allow_root": true }
<小时>
如何在 SpBowerBundle symfony 包中执行此操作:
可能您还没有在 SpBowerBundle 配置中将 sp_bower.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
但你应该有:
allow_root: true
所以在 app/config/config.yml 添加这个包配置
so in app/config/config.yml add this bundle config
sp_bower:
allow_root: false # optional
捆绑配置参考(所有设置):https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md
bundle config reference (all settings): https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md
这篇关于从 root 用户运行 bower,这可能吗?如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!