Title: test_runner: directory arguments to --test fail with MODULE_NOT_FOUND on Windows (regression since v20) · Issue #64555 · nodejs/node · GitHub
Open Graph Title: test_runner: directory arguments to --test fail with MODULE_NOT_FOUND on Windows (regression since v20) · Issue #64555 · nodejs/node
X Title: test_runner: directory arguments to --test fail with MODULE_NOT_FOUND on Windows (regression since v20) · Issue #64555 · nodejs/node
Description: Version test_runner: directory arguments to --test crash with MODULE_NOT_FOUND instead of being searched (since v21) Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps will reproduce the bug? Create a directo...
Open Graph Description: Version test_runner: directory arguments to --test crash with MODULE_NOT_FOUND instead of being searched (since v21) Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps ...
X Description: Version test_runner: directory arguments to --test crash with MODULE_NOT_FOUND instead of being searched (since v21) Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps ...
Opengraph URL: https://github.com/nodejs/node/issues/64555
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_runner: directory arguments to --test fail with MODULE_NOT_FOUND on Windows (regression since v20)","articleBody":"### Version\n\ntest_runner: directory arguments to --test crash with MODULE_NOT_FOUND instead of being searched (since v21)\n\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.26200.0 x64\n```\n\n### Subsystem\n\ntest_runner\n\n### What steps will reproduce the bug?\n\nCreate a directory containing a single test file:\n\n`tests/sample.test.mjs`:\n\n```js\nimport test from 'node:test';\ntest('ok', () => {});\n```\n\nThen, on Windows, pass the directory to the test runner:\n\n```console\nnode --test tests\nnode --test tests/\nnode --test tests\\\n```\n\nAll three fail with `MODULE_NOT_FOUND` — the directory is executed as if it\nwere a test file instead of being searched for test files.\n\nFor contrast, all of the following work:\n\n- `node --test` with no arguments in the same folder (default discovery finds and runs the test)\n- the same three commands on Node v20.20.2 on Windows\n- passing a directory on Linux/macOS\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, on Windows, whenever a directory path is passed as an argument to --test.\n\n\n### What is the expected behavior? Why is that the expected behavior?\n\nPassing a directory to `node --test` should recursively search it for test\nfiles and run them, as documented, as Node v20 does on Windows, and as current\nversions still do on Linux/macOS.\n\n\n### What do you see instead?\n\nThe directory is treated as a single test file and executed directly, which\nfails in the module loader:\n\n```console\nPS C:\\Users\\KIIT\\node-bug-repro> node --test tests/\nnode:internal/modules/cjs/loader:1368\n throw err;\n ^\n\nError: Cannot find module 'C:\\Users\\KIIT\\node-bug-repro\\tests'\n at Function._resolveFilename (node:internal/modules/cjs/loader:1365:15)\n at defaultResolveImpl (node:internal/modules/cjs/loader:1021:19)\n at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1026:22)\n at Function._load (node:internal/modules/cjs/loader:1175:37)\n at TracingChannel.traceSync (node:diagnostics_channel:322:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)\n at node:internal/main/run_main_module:36:49 {\n code: 'MODULE_NOT_FOUND',\n requireStack: []\n}\n\nNode.js v22.18.0\n✖ tests (70.2044ms)\n 'test failed'\nℹ tests 1\nℹ suites 0\nℹ pass 0\nℹ fail 1\nℹ cancelled 0\nℹ skipped 0\nℹ todo 0\nℹ duration_ms 79.0802\n\n✖ failing tests:\n\ntest at tests:1:1\n✖ tests (70.2044ms)\n 'test failed'\n```\n\nThe output is identical for `node --test tests` and `node --test tests\\`.\n\n\n### Additional information\n\nThis appears to be a regression between v20.20.2 (works) and v22.x (broken).\nPossibly related to the test runner's file discovery moving to the internal\nglob implementation (`createTestFileList` in `lib/internal/test_runner/runner.js`),\nwhere a directory pattern seems to match the directory itself rather than\nbeing expanded to the test files inside it.\n\nHappy to work on a fix if a collaborator confirms this is a bug.\n","author":{"url":"https://github.com/dhruvvv0913","@type":"Person","name":"dhruvvv0913"},"datePublished":"2026-07-17T10:51:16Z","url":"https://github.com/nodejs/node/issues/64555"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b690f455-4fad-3a83-75bf-a796c6fb0500 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E6E:242B39:580B37:77DC04:6AED216D |
| html-safe-nonce | 127fb6cae3b4c8a47775c13851b55def19703d76feba2023bf4fe4836e489388 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTZFOjI0MkIzOTo1ODBCMzc6NzdEQzA0OjZBRUQyMTZEIiwidmlzaXRvcl9pZCI6IjI3OTI4MzI0MjYyMzQ5NDU5MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a3521b93f66e240a08a152316e61af8a5950a09c95db7c5b014fe877905d0f57 |
| hovercard-subject-tag | issue:4910613738 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64555/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7711e17da6213f9fbcef3588a56882e04ce73f4be1b5114b4f4f4e5a2086aa02/nodejs/node/issues/64555 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7711e17da6213f9fbcef3588a56882e04ce73f4be1b5114b4f4f4e5a2086aa02/nodejs/node/issues/64555 |
| og:image:alt | Version test_runner: directory arguments to --test crash with MODULE_NOT_FOUND instead of being searched (since v21) Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dhruvvv0913 |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width