【问题标题】:JEST with Angular SyntaxError: Unexpected token 'export' [duplicate]JEST with Angular SyntaxError: Unexpected token 'export' [重复]
【发布时间】:2022-02-03 21:02:19
【问题描述】:

ProjectDir\node_modules\lodash-es\lodash.js:10 从'./add.js'导出{默认为添加}; ^^^^^^

SyntaxError: 意外标记“导出” 在 Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1728:14) 在对象。 (../../node_modules/ng2-charts/fesm2015/ng2-charts.mjs:5:23)

【问题讨论】:

  • 这个问题已经回答了。 Jest 与节点一起运行,import/export 分解节点进程将它们更改为导入/导出以要求

标签: javascript typescript jestjs ts-jest


【解决方案1】:

我设法通过以下链接通过一些变体解决了这个错误,但解决我的问题的方法是将以下配置添加到“jset.config.js”文件中:

moduleNameMapper: {
  "lodash-es": "lodash",
}

Jest setup "SyntaxError: Unexpected token export"

【讨论】:

    猜你喜欢
    • 2022-10-05
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    • 2021-03-22
    • 1970-01-01
    • 2019-11-10
    • 2019-04-24
    • 1970-01-01
    相关资源
    最近更新 更多