jquery-sortablejs icon indicating copy to clipboard operation
jquery-sortablejs copied to clipboard

Sortable is not a constructor

Open treyan94 opened this issue 5 years ago • 8 comments

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?

treyan94 avatar Oct 08 '19 13:10 treyan94

@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.

owen-m1 avatar Oct 09 '19 12:10 owen-m1

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!

dammainikilraj avatar Oct 15 '19 19:10 dammainikilraj

This issue happens with the newer versions of sortablejs.

Downgraded to 1.9, all fine.

Padam87 avatar Oct 16 '19 18:10 Padam87

Downgrade is (often) not the best solution.

To 1.10+ try:

/**
 * SortableJS
 */
window.Sortable = require('sortablejs').Sortable;

mariovalney avatar Feb 26 '20 18:02 mariovalney

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

dartanian300 avatar Jul 29 '21 13:07 dartanian300

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

barbuslex avatar Dec 03 '21 15:12 barbuslex

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

try Sortable.Sortable.

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

daocatt avatar Jan 07 '22 05:01 daocatt