I am trying to use bootstrap not only in html but also in my JavaScript/TypeScript. I imported bootstrap min js and min css in my html. In my TypeScript used this: import * as bootstrap from "bootstrap";
When I try to use this code:
var myModal = new bootstrap.Modal(document.getElementById('popup'), {
keyboard: false
})
myModal.hide()
the chrome console said:
Uncaught TypeError: Failed to resolve module specifier "bootstrap". Relative references must start with either "/", "./", or "../".
I believe you don't need any imports in this case, you can use it without import.
var myModal = new bootstrap.Modal(document.getElementById('popup'), {
keyboard: false
});
console.log(myModal);
<div id="popup">popup</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>