How do I install bower using package.json and npm install?
Asked Answered
N

3

17

How do I install bower using package.json and npm?

I have my package.json file setup like so..

{
    "name": "myprogramname",
    "version": "0.0.1",
    "devDependencies": {
        "bower": "1.2.6"
        //other dependencies are listed as well
    }
}

from the command line I run

npm install

It installs all of my dependencies in devDependencies except bower. Any reason for this?

Also,

which bower

returns nothing

Newsy answered 19/2, 2014 at 19:34 Comment(1)
@mpm That does work, but it would be nice to have it in package.json so that other devs checking out my branch could install everything with just npm install.Newsy
R
18

Npm did actually install Bower but not globally. If you check your node_modules/ directory, it should be there.

Therefore, it IS accessible for other developers at this path:

node_modules/bower/bin/bower
Radnorshire answered 19/2, 2014 at 22:20 Comment(2)
Also accessible via node_modules/.bin/bower. npm run adds this .bin/ to the PATH, so you can avoid dealing with the exact path by writing the commands you'll need in scripts section and using npm run.Mobility
A great way to run bower install right after npm install was described here.Hungry
U
1

A neater way to use a local install of bower is shown here.

Basically you need to use "npm run bower install" instead of "bower install" if you install bower through NPM locally and don't have it installed globally on your computer.

Unsure answered 21/2, 2018 at 9:41 Comment(1)
I liked this approach for running builds on multiple machines where I didn't want to have to worry about any box config besides installing Node.Wigfall
B
0

You installed locally and that's a good idea as you won't impact your other projects Bower versions.

You can now run bower with the local node executer:

npx bower
Brookebrooker answered 8/6 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.