Bootstrap - Uncaught TypeError: Cannot read property 'fn' of undefined
Thanks to the answer from Griford I managed to get my Angular&Electron app running with Bootstrap. All I wanted to contribute here is that no external file is needed - you can initialize JQuery and Bootstrap in a script block also:
<script>
window.$ = window.jQuery = require('jquery');
window.Bootstrap = require('bootstrap');
</script>
This works for me with the following versions (Electron 2.0.7):
"bootstrap": "^4.1.3",
"jquery": "^3.3.1",
"popper.js": "^1.14.4"
NOTE: no other script integration is needed for using Bootstrap when initialized by the two lines above. The only thing you need in addition is the CSS (in my case added to the bundle via angular.json).
In my case, I had the ordering of the imports of scripts wrong. The bootstrap import should come after the popper and jquery imports.
Since Bootstrap v4.+ depends on popper.js and jquery
"scripts": [
"./node_modules/jquery/dist/jquery.slim.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
I found a way to solve the problem.
I added a script in the index.html:
<script src="scripts/script.js"></script>
and this is the content of script.js:
window.$ = window.jQuery = require('jquery'); // not sure if you need this at all
window.Bootstrap = require('bootstrap');
and we can remove these lines from index.html to avoid double import:
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/popper.js/dist/umd/popper.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
I found this solution at: https://github.com/understrap/understrap/issues/449, under the comment from karo1915.