@jaysheel can you share your package.json file?
jQuery is not defined error.
Hi I wanted to add Material Design to my project, just importing the mdb.min.js file would sometimes create an error $(...).materialSelect is not defined. I found following solution https://gist.github.com/PabloCamp0s/a22b810af012d6110e98cb7539e96484#file-material-design-bootstrap-js
After adding the .scss and .js file. npm run watch compiled all the asset successfully. But now when I open the page I get following error
Uncaught ReferenceError: jQuery is not defined
<anonymous> jQuery
js app.js:710
__webpack_require__ app.js:2637
<anonymous> material-design-bootstrap.js:4
my app.js file look like this
require('./bootstrap');
import './material-design-bootstrap.js'
my boostrap.js file looks like this
window._ = require('lodash');
try {
window.Popper = require('popper.js').default;
global.$ = global.jQuery = require('jquery');
// require('bootstrap');
require('jquery-smooth-scroll')
} catch (e) {}
require('overlayscrollbars');
require('../../vendor/almasaeed2010/adminlte/dist/js/adminlte');
import Vue from 'vue';
window.Vue = Vue;
export const bus = new Vue();
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
let token = document.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
I have already install jquery using npm install jquery
and I also tried adding following to the top of webpack.mix file
mix.autoload({
jquery: ['$', 'window.jQuery']
});
but still get
jQuery is not defined error
I have spend 4hrs trying to find a solution but no luck, can someone please point out what I am missing or doing wrong.
Thank you Jaysheel
Please or to participate in this conversation.