加载配置时出错 - 您似乎在使用本机 ECMAScript 模块配置文件 (Jest) [英] Error while loading config - You appear to be using a native ECMAScript module configuration file (Jest)

查看:28
本文介绍了加载配置时出错 - 您似乎在使用本机 ECMAScript 模块配置文件 (Jest)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新.

当我提出拉取请求时出现此错误.有一个 github 工作流审计,它对拉取请求运行检查,并从另一个存储库加载测试文件.

This error is coming up when I am making a pull request. There is a github workflow audit that runs checks on the pull request and it loads the test file from another repository.

- name: Run Audits
      run: npx jest audits/ch-2 --json --outputFile=audits/ch-2.json --noStackTrace


Test suite failed to run

    /Users/frankukachukwu/StudioProjects/covid-19-estimator-tksilicon-js/babel.config.js: Error while loading config - You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.

我该如何解决这个问题?

How do I solve this issue?

推荐答案

SOLVED:对于遇到此问题的任何人.这与 Babel 设置有关.babel.config.extension 使用 .mjs、cjs 或 js 扩展名.在我运行 LTE Node 12.6.2 的情况下.我需要在目录 babel.config.cjs 的根目录下进行此配置.当使用type"=module"时,cjs 适用于 Nodejs.在 babel 文档上查看更多相关信息.

SOLVED: For anyone who encounters this problem. This has got to do with Babel settings. The use of .mjs, cjs or js extension for the babel.config.extension. In my case where I was running LTE Node 12.6.2. I needed this configuration at the root of my directory babel.config.cjs. cjs is what is applicable for Nodejs when using "type"="module". See more about it here on babel docs.

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current'
        }
      }
    ]
  ]
};

还有根目录下的 jest.config.cjs.

And jest.config.cjs at the root too.

这篇关于加载配置时出错 - 您似乎在使用本机 ECMAScript 模块配置文件 (Jest)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆