Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install bower dependencies using npm install?

Tags:

npm

bower

I want npm install to install the bower dependencies as well. I have a bower.json file containing frontend packages and there is package.json file which contains the backend packages. After i run npm install, node_modules are installed whereas the dependencies mentioned in bower.json file are not installed.

I don't want to use bower install rather I want to do all this with npm install command.

like image 212
Programmer Avatar asked Oct 15 '15 10:10

Programmer


People also ask

How npm install specific dependencies?

For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.

How do I install bower components?

You can also create a bower. json file and define multiple packages name with or without version. Navigate to your project folder directory and run the command “bower install”. It will download and install all the packages in your bower_components folder.

Does bower use npm?

Bower depends on Node. js and npm. Also make sure that git is installed as some bower packages require it to be fetched and installed.

Will npm install install all dependencies?

By default, npm install will install all modules listed as dependencies in package.


1 Answers

It's quite simple. If you have bower listed in package.json as dependency you may add postinstall script to your package.json as follows:

"scripts": {
  "postinstall": "bower install"
}

and running npm install will launch also bower install automatically

like image 109
Michal Moravcik Avatar answered Sep 21 '22 19:09

Michal Moravcik