taptapship / wiredep

Wire Bower dependencies to your source code.
MIT License
1.15k stars 142 forks source link

bowerJson configuration does not give any hints if the path is erronous #197

Closed kennethlynne closed 8 years ago

kennethlynne commented 9 years ago

I am trying to configure wiredep to use a bower.json in another directory, and a custom bower_components directory. No success.

var bowerDeps = wiredep({});

Throws ENOENT, no such file or directory '..../bower.json' :heavy_check_mark:

var bowerDeps = wiredep({
    bowerJson: 'does not exist'
});

//bowerDeps is { packages: {} }
// no errors reported?!
stephenplusplus commented 9 years ago

Yeah, throwing would be a good idea here: https://github.com/taptapship/wiredep/blob/571d46975b4a8b0aa038b3b320c7970e97f537a7/wiredep-cli.js#L58. PR welcome.

stephenplusplus commented 9 years ago

For some reason I thought you were using the cli. bowerJson is supposed to be an object, the contents of your bower.json file.

telemakhos commented 9 years ago

@stephenplusplus @kennethlynne I'm having a similar problem with this folder structure:

├── client
│   ├── bower.json
│   ├── bower_components
│   └── src
├── gulpfile.js
├── package.json
└── server

In the gulpfile I was passing the options as paths like this:

var wiredepOptions = {
  exclude: [/bootstrap.js$/, /bootstrap\.css/],
  directory: 'client/bower_components',
  bowerJson: 'client/bower.json'
};

but has been failing silently and nothing is injected in the html. Then after reading this thread I try to pass bower.json as an object with:

var jsonObj = require("./client/bower.json");
var wiredepOptions = {
  exclude: [/bootstrap.js$/, /bootstrap\.css/],
  directory: 'client/bower_components',
  bowerJson: jsonObj
};

but fails warning about packages not installed ..

EDIT: Nevermind, I was writing a path wrongly. It works for me with:

 bowerJson: require("./client/bower.json")