Multiple Bower json files - bower

I have the bower.json file in my main app directory (of my node and angular apps).
Then in the bower_components directory there are in each respective component/module another bower.json file.
Why are they needed?

Each bower dependency you import in your project is a complete module that you will depend on. Therefore this component must have a name, a version and may come with its own bower dependencies too, that's what the bower.json is for.
It's like a big tree of packages linked by dependencies where your application sits on top.
You can read the official documentation to learn more on the bower.json file and see all the options available.

Related

How to include files in dart package

I've a package which ships with some lib's(*.so and *.dll), when i try accessing them from my a project, it always returns no such file or directory.
I think whenever a plugin is being used, the working directory is pointing at the directory of project.
One way to fix this is to ask the user to download the lib's into there directory. But that defeats the purpose of a package.
Is there anyway to make dart find the lib in the package directory instead of the current project.

bower.json and .bowerrc missing from ASP .NET MVC template

While the Visual Studio and Visual Studio Code MVC templates comes with some client packages such as jQuery, jQueryValidation, bootstrap etc. the bower.json and .bowerrc files are completely missing, so when I go into the VS bower package manager I don't see the already installed packages which is quite annoying.
The thing is this started happening to me 2 weeks ago( around the time I tried npm package manager and did a VS Code update), how can I re-enable bower appearing with the MVC template?
This might be related to bower being deprecated. Those libraries in the template are no longer managed by bower thus they don't show in the manager. If you manually add the bower.json and .bowerrrc files you might be able to continue using bower for js library dependency management. First delete the local copies of the js files that were not added by bower, then re-add them using bower.
However, bower recommends using yarn for js library dependency management. For the client packages jquery, jquery-validation, and bootstrap you could use yarn, npm, or local copies. But for large common libraries like jquery you may want to include from Google's CDN https://developers.google.com/speed/libraries/#jquery

How do I include libraries that installed via NPM to my MVC project on Visual Studio 2017

I am trying to move from Bower to NPM.
While I was using Bower, it was easy to configure the .bowerrc file and have the downloaded libraries in a directory such as wwwroot/lib
Now, I am developing a ASP.Net Core MVC app and trying to use NPM as my default package manager. By using Command Line in Visual Studio 2017, NPM creates package.json file and download libraries to node_modules folder. Then, what is next? How can I get JS or CSS files like I used to have in wwwroot/lib director?
Ok, so heres' the thing.
NPM: Node JS package manager, helps you to manage all the libraries your software relays on. You would define your needs in a file called package.json and run npm install in the command line... BANG your packages are downloaded and are ready to use. Could be used both for front-end and back-end.
resource: https://www.quora.com/What-are-the-differences-between-NPM-Bower-Grunt-Gulp-Webpack-Browserify-Slush-Yeoman-and-Express
Now, here's where NPM stops and his dear friend Gulp takes over. I can't type all of it, but to have your css and js files in a folder (and do whatever you want with them) you'll have to use an automation tool (I personally use Gulp but there's a bunch of them out there).
It's easy to set up and the documentation is here:
https://gulpjs.com/
Gulp will basically be responsible of how and where your css files get compiled. It will base its requests for packages in the node_modules folder. So you're good to go. Configure gulp and you should be on your way.
There's also webpack. Never used it, but it seems to be the future of automation:
https://webpack.js.org/
I'd suggest using webpack.

What is the right way of managing dependencies in yeoman app which are not exist in bower?

I'm using yeoman and it's a great tool. It uses bower for managing dependencies and it assumes you would have all dependencies listed in bower file and then install it in bower_components folder and link them from the your html. But I didn't find any info about the case when some of project dependencies(js or css) are not under bower (for example, it could be some commercial libraries, purchased by developer and not available in open source). How should I manage this case? Let's assume general yeoman webapp template. Where should I store js and css from the libraries which are not under bower?
If the dependency you want to add to your project is not managed by Bower, then it should be separate from your "bower_components" dir. That directory should only have things that Bower controls: i.e., things installed with this command:
bower install
You should create a "lib" dir that has third party components that you install and update manually.
app/
├--bower_components/
│ └--angular/
└--src/
└--css/
└--js/
└--lib/
├--manual_dependency/
└--other_dependency/

how do I specify the installation location of a bower package?

I'd like to use bower in install packages. I'd also like to have the packages in specific places. In particular, I'd like my javascript in '/js'.
You can set a custom directory for where you would like bower to install all the listed dependencies in the bower.json file. Here's a quick from bower's documentation of .bowerrc:
Custom install directory
A custom install location can be set in a .bowerrc file using the
directory property. The .bowerrc file should be a sibling of your
project's bower.json.
{
"directory": "public/bower_components"
}
One of the benefits of Bower is how simple it is. One of the main downfalls of Bower is how simple it is. I do not believe that bower supports setting custom install locations for each dependency. You may have to rely on another tool to do that.
Here's a similar Stack Overflow question about install bower dependencies to different folders. While bower itself is not able to do what you ask, there are a number of tools that add such functionality:
npm bower installer (using npm)
grunt bower task (using
grunt)
grunt bower organizer (using grunt)

Resources