Uncaught Error: Script error for "popper.js", needed by: bootstrap
https://requirejs.org/docs/errors.html#scripterror
at makeError (require.js:168)
at HTMLScriptElement.onScriptError (require.js:1738)
This error is caused by Bootstrap’s dependence on the popper.js component. Bootstrap relies on jQuery or some plug-ins that depend on popper.js.
I found a solution online.
require(["popper"], function(popper) {
// set popper as required by Bootstrap
window.Popper = popper;
require(["bootstrap"], function(bootstrap) {
// do nothing - just let Bootstrap initialise itself
});
});
Try it, the problem is still unsolved.
Then start with bootstrap.
The previous code in bootstrap looks like this.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ?factory(exports, require('popper.js'), require('jquery')) :
typeof define === 'function' && define.amd ?define(['exports', 'popper.js', 'jquery'], factory) :
(factory((global.bootstrap = {}),global.Popper,global.jQuery));
}(this, (function (exports,Popper,$) { 'use strict';
Manually change the configuration in RequireJS to require Paths instead of popper.js. My configuration looks like this.
'popper': 'popper.js/dist/umd/popper.min',
Therefore, directly change the first few lines of bootstrap source code popper.js to popper to solve the problem.
However, I think it is inappropriate to change the source code in this way. So he looked for a solution.
The ultimate solution is this.
require.config({
baseUrl: '/vendors',
paths: {
'jquery': 'jquery/dist/jquery.min',
'bootstrap': 'bootstrap/dist/js/bootstrap',
'popper': 'popper.js/dist/umd/popper.min',
...
},
shim: {
'bootstrap': ['jquery']
},
map: {
'*': {
'popper.js': 'popper'
}
}
});
The core solution is:
Add a map configuration in the configuration of require
‘popper.js’: ‘popper’
And then I met,
Datatables.net – BS4 relies on datatables.net as well.
Add a row to the map to configure:
‘datatables.net’: ‘datatables’
Reproduced in: https://my.oschina.net/justplay/blog/2992283
Read More:
- Uncaught Error: Bootstrap‘s JavaScript requires jQuery
- SCRIPT1002: syntax error File: 0. chunk.js ,SCRIPT5009: ‘Map‘ is undefined File: 0. chunk.js -Solutions
- chunk-vendors.7142f8da.js:1 Uncaught SyntaxError: Unexpected token ‘<‘
- A method of collecting JS dynamic content by PHP
- React bootstrap loading and how to use modules
- JS uses the and or operator, and an error is reported: uncaught rangeerror: maximum call stack size exceeded
- Error reported by nodejs server of CentOS system: solution to cannot find module ‘jQuery’
- Transfer: completely solve the problem that the browser home page is tampered by deleting the script file
- Baidu editor echo JS error uncaught syntax error: invalid or unexpected token
- Tomcat9 Error: Could not find or load main class org.apache.catalina.startup.Bootstrap
- The version number of robot JS running by electron does not match
- ERROR Invalid options in vue.config.js: “plugins“ is not allowed
- Error: [1] bootstrap checks failed…
- Spring cloud config does not read bootstrap.properties/yml
- LR11 load correct script, error: – 27778 solution
- Vue router click the menu bar and the same module reports an error Vue router.esm.js? 2215:2065 Uncaught (in promise) Error
- Error: ‘default’ is not exported by node_ modules/qs/lib/ index.js
- Events.js:167 throw er appears when starting node service under linux; // Unhandled ‘error’ event solution
- CentOS solves the problem of modulenotfounderror when salt calls python3 script remotely, and solves the problem that PIP3 module cannot be shared by different users
- Uncaught type error: cannot read property ‘MSIE’ of undefined