Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
Error de tipo no detectado: $(...). no es una función cuando importo una biblioteca con Webpack

Estoy tratando de importar una biblioteca dentro de mi paquete y lo intento de todas las formas, pero cada vez que aparece un error.

La biblioteca es Justified-Gallery, pero a veces esto también sucede con otra biblioteca y tengo que entender dónde está el problema.

Estoy usando webpacker con Rails.

Este es mi punto de entrada, y lightGallery , otra biblioteca que estoy usando, está funcionando.

 import 'lightgallery/scss/lightgallery-bundle' // init vendor import lightGallery from 'lightgallery' import lgThumbnail from 'lightgallery/plugins/thumbnail' import lgZoom from 'lightgallery/plugins/zoom' window.lgZoom = lgZoom window.lgThumbnail = lgThumbnail window.lightGallery = lightGallery require('justifiedGallery') // init global user javascript import './js/init.js';

Init.js es mi script principal

 import NavbarSingleTon, { Navbar } from './navbar'; import GallerySingleTon, { Gallery } from './gallery'; (function init() { document.addEventListener('DOMContentLoaded', () => { Navbar.init(); Gallery.init(); }); }());

Y finalmente esta es mi galería.js

 export class Gallery { constructor($el) { $el.justifiedGallery({ captions: false, lastRow: "hide", rowHeight: 180, margins: 5 }) .on("jg.complete", function () { window.lightGallery( document.getElementById("dmove_gallery"), { autoplayFirstVideo: false, pager: false, galleryId: "dmove", plugins: [lgZoom, lgThumbnail], mobileSettings: { controls: false, showCloseIcon: false, download: false, rotate: false } } ); }); } static init() { $(".gallery-container").each((i, el) => new Gallery($(el))); } }

El error que tengo en la consola es

 gallery.js:5 Uncaught TypeError: $(...).justifiedGallery is not a function

Trato de entender por qué, y require('justifiedGallery' ) requiere este script

intento con

 import justifiedGallery from 'justifiedGallery' window.justifiedGallery = justifiedGallery

Pero nada... No puedo resolver este problema.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!