Search code examples
javascriptnpmimportquill

Quill is not defined when i import from node_modules


I wanna use quill in my project(laravel)

When i require quill from cdn my code working

but when import from node_modules i got this error :

Quill is not defined 

what can i do?

my code :

import 'quill/quill';
var quill = new Quill('#editor', {
    theme: 'snow',
});

Solution

  • You need to import Quill using the ES6 Syntax or the CommonJS require syntax.

    Change the line:

    import 'quill/quill';
    

    to ES6 Syntax:

    import Quill from 'quill';
    

    Or CommonJS with Require

    const Quill = require("quill");
    

    Making the whole thing something like:

    const Quill = require("quill");
    var quill = new Quill('#editor', {
        theme: 'snow',
    });