Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using @swc-node/register with Mocha leads to errors #784

Closed
martinslota opened this issue Jun 3, 2024 · 0 comments
Closed

Using @swc-node/register with Mocha leads to errors #784

martinslota opened this issue Jun 3, 2024 · 0 comments

Comments

@martinslota
Copy link

When Mocha is used to run test files written in Typescript along with --import=@swc-node/register/esm-register, the following kind of error gets thrown:

ReferenceError: require is not defined in ES module scope, you can use import instead
    at file:///path/to/swc-node-register-mocha-bug/node_modules/mocha/bin/mocha.js:9:29
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

A specific minimal-ish reproduce can be found in this repository. In case that reproduce does not use @swc-node/register as it is intended to be used, I'm happy to adjust it and potentially close this issue.

This issue relates to #762 which got fixed initially, and the fix did work, but the subsequent 1.9.1 release of @swc-node/register led to this other error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants