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

156
Views
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
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!