question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The jquery and bootstrap not included

See original GitHub issue

I run the bower install for bootstrap:

bower install bootstrap4-dist --save

And include the css and js in my base.nunjucks file like this

<link rel="stylesheet" href="../../bower_components/bootstrap4-dist/dist/css/bootstrap.css">
<link rel="stylesheet" href="{{baseUrl}}styles/main.css"/>
<script src="{{baseUrl}}scripts/main.js"></script>

… {% block scripts %}{% endblock %} <script src="../../bower_components/bootstrap4-dist/dist/js/bootstrap.min.js"></script>

The path is correct but it shows the files can’t be loaded. So I changed the link to cdn. The bootstrap style works. But it shows another error message:

Uncaught Error: Bootstrap’s JavaScript requires jQuery

Isn’t JQuery preinstalled by the generator? Please help. Thanks.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
DDaemscommented, Jan 19, 2016

Try this:

npm install browserify-shim --save-dev

package.json

  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
  "browser": {
    "bootstrap": "./bower_components/bootstrap-sass/assets/javascript/bootstrap.js",
    "jquery": "./node_modules/jquery/dist/jquery.js"
  },
  "browserify-shim": {
    "jquery": "$",
    "bootstrap": {
      "exports": null,
      "depends": "jquery:jQuery"
    }
  },

main.js

import ‘jquery’; import ‘bootstrap-sass’;

1reaction
DDaemscommented, Nov 6, 2015

This is how i got it working: npm install bootstrap-sass --save

@import node_modules/bootstrap/dist/css/bootstrap

for the javascript part:

npm install browserify-shim --save-dev

package.json

  "browserify": {
    "transform": [ "browserify-shim" ]
  },
  "browser": {
    "bootstrap": "./node_modules/bootstrap/dist/js/bootstrap.js"
  },
  "browserify-shim": {
    "bootstrap": {
      "exports": null,
      "depends": "jquery:jQuery" // note: bootstrap uses jQuery instead of $
    }
  },

main.js

import ‘bootstrap’;

I though the block appends styles/scripts where supposed to be used. But apperently i was wrong, this took me a while to figure out though.

@bagusflyer

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript · Bootstrap v5.0
Plugins can be included individually (using Bootstrap's individual js/dist/*.js ), or all at once using bootstrap.js or the minified bootstrap.min.js (don't ...
Read more >
Bootstrap 5 Removes jQuery Dependency - InfoQ
The Bootstrap 5 framework has removed jQuery as a requirement. It saved 85KB of minified JavaScript, which could be significant as Google starts ......
Read more >
The jQuery library is not found in Bootstrap - Stack Overflow
It's because you are trying to use (as in, you're referencing the script file) Bootstrap before you reference jQuery.
Read more >
Does Bootstrap include jQuery? - Quora
The Bootstrap 5 framework has removed jQuery as a requirement. It saved 85KB of minified JavaScript, which could be significant as Google starts...
Read more >
How to add Bootstrap to HTML (Step by Step Guide)
Hence, before loading the Bootstrap JavaScript file, include the jQuery and ... Bootstrap 5 no longer needs jQuery as a dependency since JavaScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found