I am creating an ASP NET MVC 5 Empty project , and manually adding my JavaScript references .
I have added this line:
<script src="./bower_components/angular/angular.min.js"></script>
Now my questions are: How do I download those packages, if I haven't added Bower to the project? How can I add it?
What you have to do is install bower, the requirements are node, npm and git installed.
Once the requirements are installed, the command to install bower is as follows:
You can then create a bower.json file using the following command:
You must answer the questions to create a custom bower.json file.
After this you can get the angular package with the following command:
The --save flag includes the dependency in your
bower.json
newly created fileAlso you should not reference those files inside bower_components directly for many reasons, for example:
What you should do is copy the files you need using some task runner like gulp or grunt .
This is how I did it: (for VS2015, sdk 1.0.0-beta6) This method does NOT install bower globally
NOTE: Made from this template:
1 - Right click on the project (in the solution explorer), then "New item" (or "New item" if the VS is in English)
2 - Add NPM Configuration file.
3 - Edit the new "package.json" file so that it includes these 3 development dependencies:
4 - Same as point 1, but selecting "Grunt Configuration File".
5 - Edit Gruntfile.js
6 - Same as point 1, but selecting "Bower Configuration File"
7 - Edit bower.json
With the dependencies that you need
8 - Right click on Grunfile.js and look for "Task Runner Explorer" (I don't know how it will be in Spanish)
9 - Once the "Task Runner Explorer" is open, double click on "bower:install". In the future when you update or add a bower package, you should do the same.
10 - As indicated in the grunt task,
targetDir: "wwwroot/lib"
you must locate the correct path in the HTML like this: