# node.js – How to change bower’s default components folder?

## The Question :

479 people think this question is useful

I’m making a new project that uses bower from twitter. I created a component.json to maintain all my dependency like jquery. Then I run bower install that installs everything in a folder named components. But I need to install the components in a different folder, e.g. public/components.

I have tried editing my components.json into:

{
"name": "test",
"version": "1.0.0",
"directory": "public/",
"dependencies": {
"jquery": "*"
}
}



or:

{
"name": "test",
"version": "1.0.0",
"componentsDirectory": "public/",
"dependencies": {
"jquery": "*"
}
}



as shown in https://github.com/twitter/bower/pull/94 but it doesn’t work.

932 people think this answer is useful

Create a Bower configuration file .bowerrc in the project root (as opposed to your home directory) with the content:

{
"directory" : "public/components"
}



Run bower install again.

76 people think this answer is useful

In addition to editing .bowerrc to setup your default install path, you can also setup custom install paths for different file types.

There is a node package called bower-installer that provides a single command for managing alternate install paths.

run npm install -g bower-installer

{
"name" : "test",
"version": "0.1",
"dependencies" : {
"jquery-ui" : "latest"
},
"install" : {
"path" : {
"css": "src/css",
"js": "src/js"
},
"sources" : {
"jquery-ui" : [
"components/jquery-ui/ui/jquery-ui.custom.js",
"components/jquery-ui/themes/start/jquery-ui.css"
]
}
}
}



Run the following command: bower-installer

This will install components/jquery-ui/themes/start/jquery-ui.css to ./src/css, etc

63 people think this answer is useful

I had the same issue on my windows 10. This is what fixed my problem

1. Delete bower_components in your root folder
2. Create a .bowerrc file in the root
3. In the file write this code {"directory" : "public/bower_components"}
4. Run a bower install

You should see bower_components folder in your public folder now

24 people think this answer is useful

## Something worth mentioning…

As noted above by other contributors, using a .bowerrc file with the JSON

{ "directory": "some/path" }

is necessary — HOWEVER, you may run into an issue on Windows while creating that file. If Windows gives you a message imploring you to add a “file name“, simply use a text editor / IDE such as Notepad++.

Add the JSON to an unnamed file, save it as .bowerrc — you’re good to go!

Probably an easy assumption, but I hope this save others the unnecessary headache 🙂

7 people think this answer is useful

Try putting the components.json file in the public directory of your application, rather than the root directory, then re-run bower install …try this in your app home directory:

cp components.json public
cd public
bower install



-3 people think this answer is useful

Hi i am same problem and resolve this ways.

windows user and vs cant’create .bowerrc file.

in cmd go any folder

install any packages which is contains .bowerrc file forexample

bower install angular-local-storage



this plugin contains .bowerrc file. copy that and go to your project and paste this file.

and in visual studio – solution explorer – show all files and include project seen .bowerrc file

i resolve this ways 🙂
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2906149923801422, "perplexity": 15412.001064265529}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-04/segments/1610704795033.65/warc/CC-MAIN-20210126011645-20210126041645-00650.warc.gz"}