Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Editor.JS SyntaxError:无法在模块外部使用导入语句_Javascript_Node.js_Syntax Error_Package.json_Editorjs - Fatal编程技术网

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

Javascript Editor.JS SyntaxError:无法在模块外部使用导入语句,javascript,node.js,syntax-error,package.json,editorjs,Javascript,Node.js,Syntax Error,Package.json,Editorjs,我正试图安装到我的项目中,但是,我一直遇到错误未捕获的SyntaxError:无法在模块外使用import语句 我能够通过CDN加载它,但由于某些原因,这无法工作 以下是到目前为止我已完成的故障排除步骤: 向JSON文件添加“type”:“module” 将type=“module”添加到脚本中 将节点的版本回滚到v11.4.0(建议通过stackoverflow从另一个页面执行此操作) 我已经在stackoverflow中搜索过了,除了这些,我找不到其他解决方案。有什么建议吗 HTML文件:

我正试图安装到我的项目中,但是,我一直遇到错误
未捕获的SyntaxError:无法在模块外使用import语句

我能够通过CDN加载它,但由于某些原因,这无法工作

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

  • 向JSON文件添加
    “type”:“module”
  • type=“module”
    添加到脚本中
  • 将节点的版本回滚到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>
    
    包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"
      }
    }
    

    您可能需要
    ,但您需要的是。如果没有捆绑机,我想你会很快遇到更多的问题。Shey@Phil我确实试过了,但它给了我这个错误CORS策略已阻止从源“null”访问位于“./editor/index.js”的脚本:跨源请求仅支持协议方案:http、data、chrome、chrome extension、https。有关我应该使用什么捆绑程序以及如何安装它的建议?
    {
      "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"
      }
    }