0

I need to include a bootstrap carousel via requirejs, the problem is that it fails to load pooper.js

Error :

Failed to load for element whose source is "https://domaine.com/popper.js".

My code:

requirejs-config.js

var config = {
    deps: [
        'js/theme'
    ],
    paths: {
        'popper': 'js/bootstrap4/popper.min',
        'bootstrap4': 'js/bootstrap4/bootstrap.min'
    },
    shim: {
        'popper': {
            'deps': ['jquery'],
            'exports': 'Popper'
        },
        'bootstrap4': {
            'deps': ['jquery', 'popper']
        }
    }
};

js/theme.js

require(['jquery', 'popper'], function(jQuery, Popper) {
    window.Popper = Popper; // re-attach to global scope
    require(['bootstrap4'], function() {
        jQuery(function() {
            //needed (even if empty) to force RequireJS to load Bootstrap
            // We can calls to bootstrap functions here.
            alert('hey');
        });
    });
});

I think that the problem comes from require(['bootstrap4'], function() { line when I comment this line I have my alert, but also the carousel doesn't work, without commenting it I have the error : Failed to load for element whose source is "https://domaine.com/popper.js".

misterpr
  • 1
  • 1
  • Use this link copy ctrl+A --> ctrl+C and after ctrl+V in your project in a js file named popper.js...after in your html page include that file popper.js and after bootstrap4.js...Bye https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.js https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js –  Apr 29 '18 at 13:28
  • Thanks for your answer, I have the same content as your link in just popper.min.js , I hanven't the popper.js but I tried now to add it `popper.js` but I have the same problem, As i said, I think the problem comes from `require(['bootstrap4'], function() {` if comment it I'll have my hey alert without the popper.js error but the carousel doesn't work – misterpr Apr 29 '18 at 13:50
  • I think you are using requireJs??maybe the problem is there maybe not require() but requirejs()....but sincerely i don't use requirejs so i don't know...i use the carousel inluding popper and bootstrap without other files...sorry i can't be helpfull –  Apr 29 '18 at 13:59
  • Okey, thanks for your time :) – misterpr Apr 29 '18 at 14:47
  • 1
    For information, I found the solution, instead of `bootstrap.min.js`, i replaced it with `bootstrap.bundle.min.js` bye – misterpr Apr 29 '18 at 15:30
  • Thanks for this comment, this really helped me. You should submit it as an answer as it would be useful for others. – crmpicco Dec 14 '18 at 07:19

0 Answers0