Ahad Cove
Ahad Cove

Reputation: 323

How to implement JQuery and Bootstrap in Electron app

I packaged my Angular2-Electron app up after I figured it was ready for production and ran into an error on the way. The errors that came up was that my boot strap and JQuery wasn't able to be found. Right now i am loading it inside my index.html through node_modules. This worked great until I had to package it. What is the best way to load JQuery and bootstrap locally so that my electron app can find it? The Error I am getting is Error cannot find module I understand the reason why, it's because when electron packs things up everything is moved to one file, I just can't figure out where and when to load up bootstrap and JQuery to that corresponding location

index.html:

 <script>window.$ = window.jQuery = require('../node_modules/jquery/dist/jquery.min.js');</script>

 <script src="../node_modules//bootstrap/dist/js/bootstrap.min.js"></script>

 <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">

 <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap-theme.min.css">

Upvotes: 2

Views: 3522

Answers (2)

Jens Habegger
Jens Habegger

Reputation: 5446

Requiring alone is not enough to load jquery, you will have to additionally reference your file in a tag:

<script>window.$ = window.jQuery = require('../node_modules/jquery/dist/jquery.min.js');</script>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>

You should also make sure that all your paths are correct (you have a double / in your bootstrap.min.js reference)

Upvotes: 3

Pravin Bala
Pravin Bala

Reputation: 9

script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"

This links helps jquery to sync your project with bootstrap elements and works with internet connection only.

Upvotes: 0

Related Questions