Isa*_*edy 5 javascript ckeditor node.js npm laravel-mix
I'm using CKEditor 5 in a Laravel project, getting it from a CDN, so initially I have not needed to run npm. But now I need an alignment plugin, so I used Laravel Mix to run npm install, and then copy the plugin to public folder. Like this:
mix.copyDirectory('node_modules/@ckeditor', 'public/@ckeditor');
Run Code Online (Sandbox Code Playgroud)
In my code, I tried to import it:
import Alignment from '/@ckeditor/ckeditor5-alignment/src/alignment.js';
Run Code Online (Sandbox Code Playgroud)
So it threw this error in console
Uncaught TypeError: Failed to resolve module specifier "@ckeditor/ckeditor5-core/src/plugin". Relative references must start with either "/", "./", or "../".
I solved it by auto replacing all @ckeditor/ckeditor5-core/src references in the plugin with /@ckeditor/ckeditor5-core/src
But now, it's throwing these import errors, and it's because of the lack of .js extension inside the plugin codes when importing
alignment.js:10 GET http://localhost:8000/@ckeditor/ckeditor5-core/src/plugin net::ERR_ABORTED 404 (Not Found)
alignment.js:12 GET http://localhost:8000/@ckeditor/ckeditor5-alignment/src/alignmentediting net::ERR_ABORTED 404 (Not Found)
alignment.js:13 GET http://localhost:8000/@ckeditor/ckeditor5-alignment/src/alignmentui net::ERR_ABORTED 404 (Not Found)
我的问题是是否有一些工具可以在这些 import 语句的末尾添加扩展,或者是否有一种更简单的方法可以在不运行 Node.js 的情况下使用此 npm 模块,因为我是npm的菜鸟。
| 归档时间: |
|
| 查看次数: |
967 次 |
| 最近记录: |