简体   繁体   English

当.bowerrc存在时,Bower不会安装软件包

[英]Bower will not install packages when .bowerrc exists

I'm trying to install packages using Bower. 我正在尝试使用Bower安装软件包。

Without a .bowerrc file, it works. 没有.bowerrc文件,它可以工作。 For example, bower install angular#1.0.6 will install nicely inside ./bower_components . 例如, bower install angular#1.0.6将很好地安装在./bower_components

If there is a .bowerrc with { 'directory' : 'public/javascripts/vendor' } , bower install angular#1.0.6 will not work. 如果有一个带有{ 'directory' : 'public/javascripts/vendor' }的.bowerrc, bower install angular#1.0.6将无效。 Actually, the output of that command is nothing. 实际上,该命令的输出是什么。 It simply prints a blank line, then the next line is my terminal prompt. 它只是打印一个空行,然后下一行是我的终端提示。 The package is not installed anywhere. 包没有安装在任何地方。

However, if there is an empty .bowerrc file, it will install the package inside ./bower_components. 但是,如果有一个空的.bowerrc文件,它将在./bower_components中安装该软件包。

Why is it not installing the packages and how can I fix it? 为什么不安装软件包,我该如何解决? (so they will install) (所以他们会安装)

Additional info: 附加信息:

No bower command works. 没有凉亭命令有效。 bower will fail similarly. bower同样会失败。 bower help too. bower help In fact, bower anything will too. 事实上, bower anything也会bower anything

I just solved this. 我刚解决了这个问题。 I uninstalled and reinstalled bower, and now it works. 我卸载并重新安装了凉亭,现在它可以工作了。 :S :S

sudo npm rm -g bower

sudo npm install bower -g

Now everything works fine! 现在一切正常!

The solution here is simple : 这里的解决方案很简单:

  1. Install Bower in your public directory ( Not your app/node master directory ) For example, mynodeapp/public - npm install bower 在您的公共目录中安装Bower(不是您的app / node主目录)例如,mynodeapp / public - npm install bower

  2. Then, set up bower from this directory : bower init 然后,从此目录设置bower:bower init

  3. Create your .bowercc file, and add to it : { "directory" : "vendor" } //Where vendor is your custom fldr 创建.bowercc文件,并添加到其中:{“directory”:“vendor”} //供应商是您的自定义文件

  4. Thats it. 而已。 Now whenever you run a bower install command from within the public directory, it will either create or save to that "vendor" directory. 现在,无论何时从公共目录中运行bower install命令,它都将创建或保存到该“vendor”目录。

Everyone seems to have trouble because they are installing Bower outside their public folder. 每个人似乎都有麻烦,因为他们正在公共文件夹之外安装Bower。

I think that you should be reinstall the bower 我认为你应该重新安装凉亭

npm rm -g bower
npm install bower -g

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM