javascript - Laravel mix not loading modules -


here's how webpack.mix.js looks:

const { mix } = require('laravel-mix');  /*  |--------------------------------------------------------------------------  | mix asset management  |--------------------------------------------------------------------------  |  | mix provides clean, fluent api defining webpack build steps  | laravel application. default, compiling sass  | file application bundling js files.  |  */  mix.js('resources/assets/js/app.js', 'public/js')    .sass('resources/assets/sass/app.scss', 'public/css'); 

then, app.js looks that:

/**  * loading lodash library.  *  * @private  */ window._ = require('lodash');   /**  * loading moment.js plugin.  */ window.moment = require('moment');  /**  * loading jquery.  */ window.$ = window.jquery = require('jquery');   /**  * loading datatable plugin.  */ window.$.datatable = require('datatables.net-bs');  /**  * loading bootstrap , associated plugins.  */ require('bootstrap-sass'); require('bootstrap-select');   /**  * importing daterangepicker module since 1  * in npm repositories outdated.  */ import './modules/daterangepicker/daterangepicker.js';   /**  * importing files required webpage.  */ import './globals.js';  // importing modals. import './modals/login.js'; import './modals/message.js'; import './modals/personaldata.js'; import './modals/forwarding.js'; import './modals/autoreply.js'; import './modals/adduser.js';  // importing pages. import './pages/.settings.js'; import './pages/.admin.users.js';  // executing main script. import './main.js'; 

then, when try use $ or jquery, throws me error, saying variables not defined. not that, none of other requires work. _ , moment undefined.

the first time i'm trying use $ in ./modals/login.js.

i'm using npm run watch automatic asset compilation, , compile every time save. have no idea why happens.


Comments