I appreciate this is not a real problem, just curious...
I'm using bower version 1.7.2 and all my projects so far have a .bowerrc file in the main project folder.
On my current project (through an oversight with .gitignore) I lost the .bowerrc file. However bower still works just fine and everything gets created where I want it.
I've read the docs on the Bower site and there is nothing to suggest that it will work without the .bowerrc file, and plenty on stackoverflow suggests that I need the .bowerrc file - ALSO - there isn't a .bowerrc file in the file tree between the project folder and root (although there are plenty around in folders that have different paths)
My question then is: does bower work ok without a .bowerrc file (e.g. defaulting to directory:bower_components) ? or is there a way to see which .bowerrc file my bower is using?
Many thanks for any reply, although completely understandable if you read this and move on, like I said, my problem is that it works, and I don't think it should...
As the docs specify, the .bowerrc file can be either in the project dir, the user home (i.e ~/.bowerrc - depends on your OS) or the root dir.
If you didn't put it anywhere Bower uses defaults as specified here.
And to answer your question - the default directory for bower packages is bower_components
Yes , I tested in my project with out .bowerrc I am able to install packages with bower.If we don't specify the .bowerrc file bower_components directory is creating in the root directly which is default. If we want "bower_components" to be in specific location that should be specified in the .bowerrc file.
For example if we want bower_components folder in "app" folder
bowerrc file should specify directory location : "directory": "app/bower_components",
But while downloading packages from git ,if you computer has any proxy settings that need to be configured in .bowerrc file. If we don't specify the proxy settings in .bowerrc we wont be able to download packages form git.
Related
I am adding to my jhipster project a new dependency "tether-shepherd", and below was my steps:
bower install tether-shepherd --save
the dependency was successfully installed & added to 'bower.json', then to add it to 'index.html' I ran below command
gulp inject
the js files was successfully added to index.html but without any .css theme files, when I dig into installed bower components for installed dependency I found all themes there in 'bower_components/tether-shepherd/dist/css/' directory but not included to index.html file, to add it I manually placed its include below loading-bar.css in section but it is automatically removed when I re-run gulp inject!, and when I add it manually outside any block this was not good for production profile
any professional way to include and bundle css files located in bower_components?
This is probably because these CSS are not referenced in the main property of your dependencie's bower.json like here, see gulp/inject.js in your project to understand how they are used.
So, either you add an overrides.main property for these dependencies in your JHipster app's bower.json to add them like JHipster does for Bootstrap or you manage them manually and copy them to src/main/webapp/content/css, (you may have to add #import to your main.css I didn't test).
How do I permanently add bower proxy to my system so I do not have to edit the .bowerrc file for every project and add
{
"proxy":"http://<proxy>:<port>",
"https-proxy":"https://<proxy>:<port>",
}
I have added the proxys to my OS with:
export HTTP_PROXY=http://<proxy_url>:<port>
export HTTPS_PROXY=http://<proxy_url>:<port>
But it seams bower does not get it. Thank you in advance for your response
Put the .bowerrc file in your home folder (it will work on Windows as well).
From http://bower.io/docs/config/:
Placement & Order
The config is obtained by merging multiple configurations by this
order of importance:
CLI arguments via --config
Environment variables
Local .bowerrc located in the current working directory
All .bowerrc files upwards the directory tree
.bowerrc file located in user’s home folder (~)
.bowerrc file located in the global folder (/)
Example of CLI arguments:
--config.endpoint-parser=
--config.storage.cache=
Example of valid environment variables:
bower_endpoint_parser is evaluated as endpoint-parser
bower_storage__cache is evaluated as storage.cache
When defining a package, Is it possible to put the bower.json file inside a subdirectory of my git repository, and reference it in other projects?
I know that the docs says to put it in the root, but I already have my own directory structure on my git repository and want to put it inside a subdirectory.
I'm wondering if exists an option inside .bowerrc file to configure bower.json location. That would solve my problem.
I know this question is pretty old but none of the answers address the OP's actual question.
It is possible to store your bower.json in a subdirectory of your project (or another project for that matter).
In your .bowerrc, use the cwd (current working directory) setting to specify where your json file is stored.
More info can be found in the bower configuration docs.
Bower will create the ./bower_components folder next to the bower.json file.
So, as long as you ensure that the paths of the js/css files are OK, you can put the components wherever you want.
In my case, I have to use different versions/dependencies for an HTML5 mobile app and a Bootstrap/Angular backend. So I have something like that:
/bower.json
/bower_components/
/app/bower.json
/app/bower_components/
Just be sure to include your bower.json files in the GIT tree and add the bower_components folders to the .gitignore file
Hope it helps
I have trouble connecting to sites with ssl, i.e. https. It can successfully download artifacts from the internet if the url begins with http.
bower install will download dependencies via https. Is there anyway make it download via http?
I had troubles with this too, and I couldn't find an elegant way to fix it. My workaround was:
Go to your global npm folder and find the "bower" folder (on Windows 7 that is "C:\Users\\AppData\Roaming\npm\node_modules").
In that folder, search the default.js file placed in node_modules\bower-config\lib\util\default.js
Inside that file you will find a "var defaults". Replace the "registry" url property from "https" to "http".
Yes, I know. This shouldn't be done like this, but at least help me to bypass the connection error.
Hope that helps!
You can change the registry used by Bower in the .bowerrc file. The default registry is: https://bower.herokuapp.com and is defined in node_modules/bower-config/lib/util/default.js (as described by Jean Manuel Arias in his answer).
To override for your project, add a value for the registry setting in .bowerrc. An example file might be:
{
"directory": "<YOUR LIBRARY INSTALL DIRECTORY>",
"registry":"http://bower.herokuapp.com"
}
In the above example, the default https registry is being overridden with the http version. A full list of the available .bowerrc settings can be found at: Bower Spec.
You can do a global override for the current user by creating a %USERPROFILE%\.bowerrc file (for windows, in Linux it is: ~/.bowerrc). Bower follows a similar search path when applying settings to NPM (see npmrc settings). This is probably a better route as it avoids cluttering your project with local settings.
This is a follow-up to this question. I'm using bower 0.7.1, and still cannot get the components to be installed anywhere else than in the components folder.
I tried adding the following line to my component.json, as per this PR:
"componentsDirectory": "public/components"
But it will still install in ./components.
I tried to create a .bowerrc file next to component.json:
{
"directory" : "public/components"
}
But I get this error when running bower install:
Error: Unable to parse local .bowerrc file: Unexpected token }
Any idea?
Actually the .bowerrc file does work, this was an issue with my IDE not saving the file properly:
{
"directory" : "public/components"
}
I'm still wondering why componentsDirectory still doesn't work in component.json, though.
While you can happily use Bower to manage the dependencies of your own personal projects, primarily the component.json is a description of your project for other people. If you share a component through the Bower registry the component.json goes with it to describe the dependencies. That is why your own local preferences like where to install components don't belong in there.
Another way to change installation directory temporarily is using --config option in command line:
bower install jquery --config.directory=/path/to/your/components
If you are creating this file in Notepad++, make sure the Encoding is set to "Encode in UTF-8 without BOM" and save as file type "Any".