[Bug]: babel-node --test internal-errors: Could not find '/app/node_modules/@babel/node/lib/_babel-node'
- Dominant language
- TypeScript
- Stars
- 44k
- Forks
- 6k
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 23
Description
### 💻
- [ ] Would you like to work on a fix?
### How are you using Babel?
@babel/register or @babel/node
### Input code
```bash
npx -p @babel/node babel-node --test
```
Or, in any project with `@babel/node` installed:
```bash
npx babel-node --test
node_modules/.bin/babel-node --test
```
### Configuration file name
_No response_
### Configuration
_No response_
### Current and expected behavior
`babel-node` prints this slightly odd error:
(for `npx -p`)
```
Could not find '/home/faux/.cache/npm/_npx/88ef5472e811fc37/node_modules/@babel/node/lib/_babel-node'
```
(for app)
```
Could not find '/var/app/node_modules/@babel/node/lib/_babel-node'
```
I was hoping it would perform the same as the experimental node 18 test framework, wherein `node --test` would go run my tests, but pre-processing them with babel.
### Environment
```
System:
OS: Linux 5.19 Ubuntu 22.10 22.10 (Kinetic Kudu)
Binaries:
Node: 18.14.0 - /tmp/fnm_multishells/52480_1676211961346/bin/node
Yarn: 1.22.10 - ~/.npm-packages/bin/yarn
npm: 9.3.1 - /tmp/fnm_multishells/52480_1676211961346/bin/npm
npmPackages:
@babel/core: ^7.20.12 => 7.20.12
@babel/node: ^7.20.7 => 7.20.7
```
### Possible solution
_No response_
### Additional context
IntelliJ's debugger thinks the stack trace here is:
```
node:internal/main/test_runner:89
createTestFileList (run_main_module:89)
main (run_main_module:141)
(anonymous function) (run_main_module:146)
```
...but I do not know what this means. It appears to contain no babel code, so, uh, I would understand if you were to tell me this was an upstream issue. I don't have much hope of them fixing it, though, so I'm reporting it here instead.
Contributor guide
Research direction
Reproduce the failure with `npx -p @babel/node babel-node --test` and the equivalent installed-package commands. Start by tracing the `@babel/node` CLI entry point and compare its handling of `--test` with Node's `internal/main/test_runner`; done means Babel-preprocessed tests run instead of the missing `_babel-node` error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100