Skip to content

Sortable is not a constructor #3

Open

Description

@treyan94

I keep getting Sortable is not a constructor when using it with Webpack in Laravel.

import Sortable from 'sortablejs';
import 'jquery-sortablejs';

window.Sortable = Sortable;
window.$ = window.jQuery = require('jquery');

It works fine when I use CDN. What could be causing this?

Activity

  1. owen-m1 commented on Oct 9, 2019

    @owen-m1
    Member

    @treyan94 Are you importing it in a NodeJS context?
    And why do you have window.Sortable = Sortable? Sortable adds itself to the window when you import it.

  2. dammainikilraj commented on Oct 15, 2019

    @dammainikilraj

    sortable error
    facing the same error from long back. could any one help me out on this.

    Added screen shot for your reference.

    Thanks in advance!

  3. Padam87 commented on Oct 16, 2019

    @Padam87

    This issue happens with the newer versions of sortablejs.

    Downgraded to 1.9, all fine.

  4. mariovalney commented on Feb 26, 2020

    @mariovalney

    Downgrade is (often) not the best solution.

    To 1.10+ try:

    /**
     * SortableJS
     */
    window.Sortable = require('sortablejs').Sortable;
    
  5. dartanian300 commented on Jul 29, 2021

    @dartanian300

    I'm having the same issue but @mariovalney's answer isn't working. Still getting the Sortable is not a constructor error. Any thoughts?

    window.Sortable = require('sortablejs').Sortable;
    import 'jquery-sortablejs';
    

    jquery sortable: v1.0.1
    sortablejs: v1.14.0

  6. barbuslex commented on Dec 3, 2021

    @barbuslex

    I have the same issue... Anyone have the solution ?

  7. daocatt commented on Jan 7, 2022

    @daocatt

    I have the same issue... Anyone have the solution ?

    try Sortable.Sortable.

    console.log(Sortable) you will see three module.

  8. raysuelzer commented on Sep 5, 2024

    @raysuelzer

    Is there any way to use a CDN version of sortableJS. I have a simple app and dont' really want to go through setting up an entire build process...

  9. maatcode commented on Feb 2, 2025

    @maatcode

    in your webpack.config.js:

    resolve: {
            modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
     },
    

    and in your .ts file:

    import Sortable = require('sortablejs');
    
    Sortable.Sortable.create(el); 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions