Editor.JS SyntaxError:无法在模块外部使用import语句

问题描述

我正在尝试将editor.js安装到我的项目中,但是,我仍然遇到错误Uncaught SyntaxError: Cannot use import statement outside a module

我可以通过CDN加载它,但是由于某种原因,它无法正常工作。

以下是我到目前为止已完成的故障排除步骤:

  1. "type":"module"添加到JSON文件
  2. type="module"添加到普通js脚本
  3. 将节点回滚到v11.4.0版本(建议从另一个页面通过stackoverflow)。

我已经搜索了stackoverflow,但除此之外找不到其他解决方案。有什么建议吗?

HTML文件

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <Meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <div  id="editorjs"></div>

    <script src="index.js"></script>

  </body>
</html>

JS文件

import EditorJS from '@editorjs/editorjs';

const editor = new EditorJS();

打包JSON文件

{
  "name": "editor","version": "1.0.0","type": "module","description": "","main": "index.js","scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },"keywords": [],"author": "","license": "ISC","devDependencies": {
    "@editorjs/editorjs": "^2.18.0"
  }
}

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)