I am trying to use swiper from swiperjs.com on my website. I installed node and added swiper as a dependency with the npm install swiper
command. I created a swiper.js
file where I am trying to import swiper:
import Swiper from "swiper";
const swiper = new Swiper(".swiper");
In the head
of my HTML I added this line to load the swiper.js
file:
<script type="text/javascript" src="http://localhost:8000/js/swiper.js"></script>
This is my package.json file:
{
"name": "sasstheme",
"version": "1.0.0",
"scripts": {
"watch": "sass --watch src/scss/style.scss style.css"
},
"devDependencies": {
"sass": "^1.49.9"
},
"dependencies": {
"swiper": "^8.0.7"
}
}
When I load the page I am getting the following error in the console:
Uncaught SyntaxError: Cannot use import statement outside a module