Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
Use npm Javascript module with webpack mix

I'm struggling with javascripts in my laravel app. I want to include instructorjs (https://www.npmjs.com/package/instructorjs), but it doesn't work. I think that script loading as modules doesn't work in combination with webpack. But I don't know where and how to import the scripts. I ended up with:

import {jqueryScrollTo} from '/node_modules/jquery.scrollto/jquery.scrollTo.min.js';
import {InstructorFactory} from '/node_modules/instructorjs/instructor.min.js'
jqueryScrollTo(window.$);

window.jqueryScrollTo = require('jquery.scrollto');
window.InstructorFactory = require('instructorjs');

in my bootstrap.js. In my view I have these lines:

const instructorFactory = require ('instructorjs');
var instructor = new instructorFactory();

My webpack.mix.js lines are:

mix.js('resources/js/app.js', 'public/js').sourceMaps().extract()
    .sass('resources/sass/app.scss', 'public/css')
    .autoload({ jquery: ['$', 'jQuery', 'window.jQuery']});

I really can't get it to work. I try to copy and move the requires and imports from file to file, but I can't find the right expression/position for it. Any help from you is very appreciated!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda