JQuery module not found using jquery-slim package?

I am using the Laravel framework with laravel-elixir, jquery-slim , vuejs, vue-resource npm packages.

My problem is that when I try to import a jquery plugin (like snackbarjs) it gives me a problem since the jquery module is not recognized.

Error:

Browserify Failed!: Cannot find module 'jquery'

I know where this problem comes from, snackbarjs in this case is trying to use the jquery plugin with this code:

(function (factory) {
if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['jquery'], factory);
} else if (typeof exports === 'object') {
    // Node/CommonJS
    module.exports = factory(require('jquery'));
} else {
    // Browser globals
    factory(jQuery);
}

My app.js file is as follows:

import $ from 'jquery-slim';
import jQuery from 'jquery-slim';
import Vue from 'vue';
import VueResource from 'vue-resource';
import Vuex from 'vuex';
import 'snackbarjs';
Vue.use(VueResource);
Vue.use(Vuex);

Is there a way snackbarjs to ignore the jquery module requirement or change the module name to "jquery" from "jquery-slim"?

Thanks in advance!

+4

All Articles