I have several Backbone plugins along with Backbone itself that I bundle into a vendor.js
file using Browserify. Backbone itself is being loaded in a module that has been modified to work with Angular. This has resulted in some what of a strange file directory that I'll layout below, which is giving me some issues with Browserifying it all together:
src/
app.js // <- requires angular-backbone and some-backbone-plugin
node_modules/
backbone/
underscore/
angular-backbone/
main.js // <- requires Backbone and Underscore here
node_modules/
backbone/
underscore/
some-backbone-plugin/
main.js // <- also requires Backbone and Underscore here
node_modules/
backbone/
underscore/
When I build src/app.js
, I get Backbone and Underscore bundled in there twice. Is there a way I can set all require('backbone')
and require('underscore')
statement to always resolve to node_modules/backbone
and node_modules/underscore
respectively?
You can try creating symlink or shortcut-link to the node_modules folder in the other directories. That way you get one place where all the node_modules are, and everything else is just a shortcut to that main one.
Examples:
ln -sF ../../../node_modules/
ln -sF ../node_modules/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.