question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slick-carousel and webpack - $(...).slick is not a function. The solution from other issues doesn't work.

See original GitHub issue

Hello. I’m trying to use slick-carousel and webpack.

I use the solutions from #2290 with ProvidePlupin and esplose-loader. jQuery and Webpack work without error. But still got the error “$(…).slick is not a function”.

Maybe the reason is in the package version in npm? In this repo last version is 1.8.0. In npmjs.com - 1.7.1 (link)

Or I missed a working solution? What kind?

Script code

import $ from 'jquery';
import 'slick-carousel';
$(".slider-wrapper").slick();

Dependencies

  "devDependencies": {
    ...
    "webpack": "^2.7.0",
    "webpack-stream": "^4.0.0",
  },
  "dependencies": {
    ...
    "jquery": "2.2.4",
    "slick-carousel": "1.7.1",
  }

Webpack config

const path        = require('path'); //npm module for absolute path like  path.resolve(__dirname, './build')
const webpack = require('webpack');
const config     = require('./gulp/config.js');


module.exports = {
    entry: './'+ config.src.jsEntryPoint,   
    output: {
        filename: 'bundle.js', 
        path: path.resolve(__dirname, './' + config.dest.js),   
    },
    watch: true, //live-reloading
    devtool: 'source-map', 


    plugins: [
        // jQuery globally
        new webpack.ProvidePlugin({ 
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery"
        }),
    ],



    module: {
        loaders: [
			{
			  test: require.resolve("jquery"),
			  use: [
				{
				  loader: "expose-loader",
				  options: "$"
				}
			  ]
			}        
		],
    }

};

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

122reactions
warslettcommented, Dec 3, 2018

there is a special place in hell for people who close github issues like this…

55reactions
Gesparocommented, Aug 1, 2018

This solution helped me to solve the problem:

import $ from 'jquery';
window.$ = window.jQuery = $;
import 'slick-carousel'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Slick Carousel Uncaught TypeError: $(...).slick is not a function
If you type in $(...).slick on the console and it reports the error, it means the file is not loaded correctly. – Joy....
Read more >
TypeError: $(...).slick is not a function in jQuery | bobbyhadz
To solve the "$(...).slick is not a function" jQuery error, make sure to load the jQuery library before loading the slick library. The...
Read more >
Slick Carousel Uncaught TypeError: $(...).slick is not a function
jQuery : Slick Carousel Uncaught TypeError: $(...). slick is not a function [ Beautify Your Computer ...
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Uncaught TypeError | Is Not A Function | Solution ... At one page I have initialized the slider and other page only has...
Read more >
jquery 32 1 min js 2 uncaught typeerror slick is not a function
Uncaught TypeError : $().slick is not a function Usually means that you either forgot to include slick.js in the page or you included...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found