How to fix the error; 'Error: Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)'
JavascriptTwitter BootstrapBootstrap 4TetherJavascript Problem Overview
I'm using Bootstrap V4 and the following error is logged in the console;
> Error: Bootstrap tooltips require Tether > (http://github.hubspot.com/tether/)
I have tried to remove the error by installing Tether but it hasn't worked. I have 'installed' Tether by including the following lines of code;
<link rel="stylesheet" href="http://www.atlasestateagents.co.uk/css/tether.min.css">
<script src="http://www.atlasestateagents.co.uk/javascript/tether.min.js"></script>
Have I 'installed' tether correctly?
Can anyone help me remove this error?
If you wish to view the error on my site, please click here and load your console.
Javascript Solutions
Solution 1 - Javascript
For Bootstrap 4 stable:
Since beta Bootstrap 4 doesn't depend on Tether but Popper.js. All scripts (must be in this order):
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
See the current documentation for the newest script versions.
Only Bootstrap 4 alpha:
Bootstrap 4 alpha needs Tether, so you need to include tether.min.js
before you include bootstrap.min.js
, eg.
<script src="https://npmcdn.com/[email protected]/dist/js/tether.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/js/bootstrap.min.js"></script>
Solution 2 - Javascript
If you're using Webpack:
- Set up bootstrap-loader as described in docs;
- Install tether.js via npm;
- Add tether.js to the webpack ProvidePlugin plugin.
webpack.config.js:
plugins: [
<... your plugins here>,
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"window.Tether": 'tether'
})
]
Solution 3 - Javascript
If you are using npm and browserify:
// es6 imports
import tether from 'tether';
global.Tether = tether;
// require
global.Tether = require('tether');
Solution 4 - Javascript
Personally I use small subset of Bootstrap functionality and don't need to attach Tether.
This should help:
window.Tether = function () {
throw new Error('Your Bootstrap may actually need Tether.');
};
Solution 5 - Javascript
If you want to avoid the error message and you are not using Bootstrap tool tips, you can define window.Tether before loading Bootstrap.
<script>
window.Tether = {};
</script>
<script src="js/bootstrap.min.js"></script>
Solution 6 - Javascript
You should done my guideline:
-
Add bellow source into Gemfile
source 'https://rails-assets.org'; do gem 'rails-assets-tether', '>= 1.1.0' end
-
Run command:
bundle install
-
Add this line after jQuery in application.js.
//= require jquery
//= require tether -
Restart rails server.
Solution 7 - Javascript
Install tether via npm like below
npm install tether --save-dev
then add tether to your html above bootstrap like below
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="jspm_packages/github/twbs/[email protected]/js/bootstrap.js"></script>
Solution 8 - Javascript
For webpack I resolved this with webpack.config.js
:
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
"window.jQuery": "jquery",
Tether: 'tether'
})
Solution 9 - Javascript
An additional note. If you check uncompressed javascript file, you will find the condition:
if(window.Tether === undefined) {
throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether)')
}
So the error message contains the required information.
> You can download the archive from that link.
Uncompressed version:
https://rawgit.com/HubSpot/tether/master/src/js/tether.js https://rawgit.com/HubSpot/tether/master/dist/css/tether.css
Solution 10 - Javascript
Using webpack I used this in webpack.config.js
:
var plugins = [
...
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
'window.jQuery': 'jquery',
'window.Tether': 'tether',
tether: 'tether',
Tether: 'tether'
})
];
It seems like Tether
was the one it was looking for:
var Tooltip = function ($) {
/**
* Check for Tether dependency
* Tether - http://tether.io/
*/
if (typeof Tether === 'undefined') {
throw new Error('Bootstrap tooltips require Tether (http://tether.io/)');
}
Solution 11 - Javascript
I was having this issue with requirejs using the newest boostrap 4 build. I ended up just defining:
<script>
window.Tether = {};
</script>
in my html head tag to fool bootstrap's check. I then added a second require statement just before the require that loads my app, and subsequently, my bootstrap dependency:
require(['tether'], function (Tether) {
window.Tether = Tether;
});
require([
"app",
], function(App){
App.initialize();
});
Using both of these in tandem and you should have no problem using current bootstrap 4 alpha build.
Solution 12 - Javascript
Works for generator-aspnetcore-spa and bootstrap 4.
// ===== file: webpack.config.vendor.js =====
module.exports = (env) => {
...
plugins: [
new webpack.ProvidePlugin({ $: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.Tether': 'tether',
tether: 'tether',
Tether: 'tether' }),
// Maps these identifiers to the jQuery package
// (because Bootstrap expects it to be a global variable)
...
]
};
Solution 13 - Javascript
For webpack 1 or 2 with Bootstrap 4 you need
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Tether: 'tether'
})
Solution 14 - Javascript
If you are using Brunch, you can add this at the end of your brunch-config.js
:
npm: {
enabled: true,
globals: {
$: 'jquery', jQuery: 'jquery', 'Tether': 'tether'
}
}
Solution 15 - Javascript
If you use require.js AMD loader:
// path config
requirejs.config({
paths: {
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/core.js',
tether: '//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min',
bootstrap: '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min',
},
shim: {
bootstrap: {
deps: ['jquery']
}
}
});
//async loading
requirejs(['tether'], function (Tether) {
window.Tether = Tether;
requirejs(['bootstrap']);
});
Solution 16 - Javascript
For you Laravel Mix users out there running Bootstrap4, you will need to run
npm installer tether --save
Then update you resources/assets/js/bootstrap.js
to load Tether and bring it to the window object.
Here is what mine looks like: (Note I also had to run npm install popper.js --save
)
window.$ = window.jQuery = require('jquery');
window.Popper = require('popper.js').default;
window.Tether = require('tether');
require('bootstrap');
Solution 17 - Javascript
UMD/AMD solution
For those guys, who are doing it through UMD, and compile via require.js
, there is a laconic solution.
In the module, which requires tether
as the dependency, which loads Tooltip
as UMD, in front of module definition, just put short snippet on definition of Tether:
// First load the UMD module dependency and attach to global scope
require(['tether'], function(Tether) {
// @todo: make it properly when boostrap will fix loading of UMD, instead of using globals
window.Tether = Tether; // attach to global scope
});
// then goes your regular module definition
define([
'jquery',
'tooltip',
'popover'
], function($, Tooltip, Popover){
"use strict";
//...
/*
by this time, you'll have window.Tether global variable defined,
and UMD module Tooltip will not throw the exception
*/
//...
});
This short snippet at the very beginning, actually may be put on any higher level of your application, the most important thing - to invoke it before actual usage of bootstrap
components with Tether
dependency.
// ===== file: tetherWrapper.js =====
require(['./tether'], function(Tether) {
window.Tether = Tether; // attach to global scope
// it's important to have this, to keep original module definition approach
return Tether;
});
// ===== your MAIN configuration file, and dependencies definition =====
paths: {
jquery: '/vendor/jquery',
// tether: '/vendor/tether'
tether: '/vendor/tetherWrapper' // @todo original Tether is replaced with our wrapper around original
// ...
},
shim: {
'bootstrap': ['tether', 'jquery']
}
UPD: In Boostrap 4.1 Stable they replaced Tether, with Popper.js, see the documentation on usage.
Solution 18 - Javascript
To add to @adilapapaya's answer. For ember-cli
users specifically, install tether
with
bower install --save tether
and then include it in your ember-cli-build.js
file before bootstrap, like so:
// tether (bootstrap 4 requirement)
app.import('bower_components/tether/dist/js/tether.min.js');
// bootstrap
app.import('bower_components/bootstrap/scss/bootstrap-flex.scss');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
Solution 19 - Javascript
And if using webpack, you will need the expose plugin. In your webpack.config.js, add this loader
{
test: require.resolve("tether"),
loader: "expose?$!expose?Tether"
}
Solution 20 - Javascript
I had the same problem and this is how I solved it. I'm on rails 5.1.0rc1
Make sure to add require jquery and tether inside your application.js file they must be at the very top like this
//= require jquery
//= require tether
Just make sure to have tether installed
Solution 21 - Javascript
Method #1: Download from Here and insert it to your projects, or
Method #2: use below code before your bootstrap script source:
<script src="https://npmcdn.com/[email protected]/dist/js/tether.min.js"></script>
Solution 22 - Javascript
I recommend following the instructions in the Bootstrap 4 documentation:
> Copy-paste the stylesheet <link>
into your <head>
before all other
> stylesheets to load our CSS.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
> Add our JavaScript plugins, jQuery, and Tether near the end of your > pages, right before the closing tag. Be sure to place jQuery > and Tether first, as our code depends on them. While we use jQuery’s > slim build in our docs, the full version is also supported.
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
Solution 23 - Javascript
I had the same problem and i solved it by including jquery-3.1.1.min before including any js and it worked like a charm. Hope it helps.