Swiper.on is not a function

I initialize a Swiper, but something goes wrong when I navigate to another identical page (structurally)


  var swiper = app.swiper.create('.main-swiper', {
		speed: 400,
		spaceBetween: 100,
		observer: true //Important to check DOM changes caused by .html() or .append()


On Slide change event:

//On Slide Change
swiper.on('slideChange', function (e) {
	var current_index = e.activeIndex; //From 0
	//Remove "active" class from all swipe indicators
	//Insert "active" class on current item
	//Bind event again, but now, looking for current_index to go to the right photo
	  $('.carousel-inner').on('click', function () {

Everything goes right on the first page. But if I click to go to the second…

Uncaught (in promise) TypeError: swiper.on is not a function

I appreciate any help

Would be good to see full example, and how these two pieces of code related, in same file/scope/etc