Browserify Shim not working

126 Views Asked by At

I have the following configuration in my package.json :

"browser": {
    "ui-bootstrap-tpls": "./node_modules/angular-ui-bootstrap/ui-bootstrap-tpls.js"
},
"browserify": {
    "transform": ["browserify-shim"]
},
"browserify-shim": {
    "ui-bootstrap-tpls": "ui-bootstrap-tpls"
}

In my Javascript I have :

require('ui-bootstrap-tpls');

But I get this error while generating browserifybundle :

cannot find module : ui-bootstrap-tpls

I do not have control over the library where the require call is made for 'ui-bootstrap-tpls'

Please help, I can confirm that the path to the ui-bootstrap-tpls.js exists.

1

There are 1 best solutions below

0
YPCrumble On

First of all, it seems like you just want to install the Angular UI Bootstrap module, not just that file. If that's the case, you should just delete your Browserify Shim directives from your package.json and try require('angular-ui-bootstrap)` in your code. You haven't explained why you actually want just that particular file vs. the entire package so it isn't straightforward to help you.

If you've installed Angular UI bootstrap via npm install angular-ui-bootstrap the path would be as follows: node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js. You've omitted the dist from the path...has someone hacked the contrib module or do you just need to change that part of your package.json?

Last - the package's main directive is index.js not ui-bootstrap-tpls.js so it's odd that you would have to require just that file. Something isn't right here.