【问题标题】:Getting 'ambiguous indirect export' error in JavaScript/TypeScript在 JavaScript/TypeScript 中出现“模糊间接导出”错误
【发布时间】:2022-11-05 20:00:31
【问题描述】:

我收到此错误: Syntax Error: ambiguous indirect export 在火狐中。可悲的是,在 Google 上找不到任何东西......

  • 这是我的导入:
<script type="module">
    import {someFunctionINeed} from "./js/functions.js";
    ...
</script>
  • 这是我的导出:
export function someFunctionINeed(cname) { ... }
  • 来自我的tsconfig.json 的一部分:
"compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "watch": true,
    "removeComments": true
}
  • 以及可能与package.json 相关的内容:
"type": "module"

我错过了什么?

【问题讨论】:

    标签: javascript html typescript module


    【解决方案1】:

    好的,我找到了解决方案:在tsconfig.json 中设置这些属性很重要:

    "module": "ESNext",
    "target": "esnext",
    

    否则,它不会按照我需要它来支持导入/导出函数的方式“编译”。

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题,显然我忘了在导出末尾添加逗号

      【讨论】:

        猜你喜欢
        • 2015-07-19
        • 2021-02-08
        • 2018-08-24
        • 1970-01-01
        • 2014-03-31
        • 1970-01-01
        • 1970-01-01
        • 2019-01-02
        • 1970-01-01
        相关资源
        最近更新 更多