Description
Current behavior
Running Cypress component testing in a Vite v5 or v6 based JavaScript project in a monorepo, where TypeScript is a transient dependency only in the root of the monorepo, results in additional warnings if the dependencies in the repo root are also installed:
(node:5542) ExperimentalWarning:
--experimental-loader
may be removed in the future; instead useregister()
:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Usenode --trace-warnings ...
to show where the warning was created)
(node:5542) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Usenode --trace-deprecation ...
to show where the warning was created)
Desired behavior
The results of running Cypress component testing in a monorepo JavaScript project should be independent of whether the TypeScript dependencies in the root of the repo have been installed or not.
Test code to reproduce
Execute first:
git clone https://github.com/cypress-io/github-action
cd github-action
git clean -xfd # if repeating tests
npm ci
cd examples/component-tests
npm ci
npm test
which shows multiple node
warnings (see above, and Debug Logs below), then execute:
rm -rf ../../node_modules
npm test
and confirm there is no longer any error for Node.js v22.14.x
only the CJS deprecation warning is output:
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
Cypress Version
First reported on Cypress version: 14.0.0
Continues to be reproducible on Cypress version: 14.2.1
Node version
v22.13.0
LTSv22.14.0
LTS
Operating System
Ubuntu 24.04.2
LTS
Debug Logs
$ npm test
> [email protected] test
> cypress run --component
DevTools listening on ws://127.0.0.1:40257/devtools/browser/ced1c3dd-9c2a-40a8-94b8-12afea482130
(node:5542) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5542) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 14.0.0 │
│ Browser: Electron 130 (headless) │
│ Node Version: v22.13.0 (/home/mike/n/bin/node) │
│ Specs: 1 found (Stepper.cy.jsx) │
│ Searched: **/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
with root dependencies installed:
cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/component-tests', '--file', '/home/mike/github/cypress-io/github-action/examples/component-tests/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/component-tests', execPath: '/home/mike/n/bin/node' } } +0ms
cypress:lifecycle:ProjectConfigIpc found typescript in /home/mike/github/cypress-io/github-action/examples/component-tests +3ms
cypress:lifecycle:ProjectConfigIpc using --experimental-specifier-resolution=node with --loader file:///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs +3ms
cypress:lifecycle:ProjectConfigIpc detected node version 22.13.0, adding --no-experimental-detect-module option to child_process NODE_OPTIONS. +1ms
cypress:lifecycle:ProjectConfigIpc detected node version 22.13.0, adding --no-experimental-require-module option to child_process NODE_OPTIONS. +0ms
cypress:lifecycle:ProjectConfigIpc trigger the load of the file +17ms
(node:6747) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6747) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
cypress:lifecycle:ProjectConfigIpc loadConfig:reply +729ms
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
when root dependencies not installed:
cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/component-tests', '--file', '/home/mike/github/cypress-io/github-action/examples/component-tests/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/component-tests', execPath: '/home/mike/n/bin/node' } } +0ms
cypress:lifecycle:ProjectConfigIpc no typescript found, just use regular Node.js +3ms
cypress:lifecycle:ProjectConfigIpc trigger the load of the file +12ms
cypress:lifecycle:ProjectConfigIpc loadConfig:reply +468ms
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.