Home » Php » php – Laravel CKEditor5 – ClassicEditor is not Defined

php – Laravel CKEditor5 – ClassicEditor is not Defined

Posted by: admin February 25, 2020 Leave a comment


I’m trying to replace an old version of CKEditor in a Laravel app due to dependency incompatibility with unisharp/laravel-ckeditor and Laravel 6. I’ve found the CKEditor 5 page with NPM installation instructions, but haven’t been able to get it working. Here is my code:





mix.js('resources/assets/js/main.js', 'public/js');


<!doctype html>
  <script src="{{ asset('js/main.js') }}"></script>

jQuery is included (somehow; somewhat unfamiliar with webpack), but running a page that extends @extends('layouts.master') results in the following:

Uncaught ReferenceError: ClassicEditor is not defined

If I remove the require() statement from main.js and simply use the CDN link, everything works as expected:

<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
<script src="{{ asset('js/main.js') }}"></script>

I’m doing something wrong, but I’m at a loss… Has anyone seen this issue before?

How to&Answers:

Quite a simple solution that the documentation fails to reference, but you need to assign the value of require() to ClassicEditor:

var ClassicEditor = require('@ckeditor/ckeditor5-build-classic');

Doing so allows correct reference in code.


Regarding Laravel included libraries examples in boostrap.js file such as pusher, axios, etc…

You may use

window.ClassicEditor = require('@ckeditor/ckeditor5-build-classic');