如何解决Editor.JS SyntaxError:无法在模块外部使用import语句
我正在尝试将editor.js安装到我的项目中,但是,我仍然遇到错误Uncaught SyntaxError: Cannot use import statement outside a module
。
我可以通过CDN加载它,但是由于某种原因,它无法正常工作。
以下是我到目前为止已完成的故障排除步骤:
- 将
"type":"module"
添加到JSON文件 - 将
type="module"
添加到普通js脚本 - 将节点回滚到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"
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。