Skip to content

TypeScript and package.json type module (ESM) shows "ExperimentalWarning: --experimental-loader" #30318

Closed
@MikeMcC399

Description

@MikeMcC399

Current behavior

If package.json is configured with Node.js type field set to module (instead of left undefined or set to commonjs), Typescript is installed and config.cypress.ts is present, then the following warning is output when running Cypress:

DevTools listening on ws://127.0.0.1:34161/devtools/browser/b3805bff-7dbc-4403-8aa2-2b24de43ca12
(node:4680) 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.3/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use node --trace-warnings ... to show where the warning was created)
(node:4680) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use node --trace-deprecation ... to show where the warning was created)

Desired behavior

Cypress should not show any warning when set up as a TypeScript project and package.json includes "type": "module" for an ESM project.

Test code to reproduce

https://github.com/MikeMcC399/cypress-test-tiny/tree/30318-ts-module

git clone --branch 30318-ts-module https://github.com/MikeMcC399/cypress-test-tiny
cd cypress-test-tiny
npm ci
npx cypress run

Cypress Version

First reported on Cypress version: 13.15.0
Continues to be reproducible on version: 14.3.3

Node version

v20.17.0 and
v22.13.1 LTS (see below for additional warnings with this version)
v22.15.0 LTS

Operating System

Ubuntu 24.04.1 LTS 24.04.2 LTS

Debug Logs

DevTools listening on ws://127.0.0.1:34161/devtools/browser/b3805bff-7dbc-4403-8aa2-2b24de43ca12
(node:4680) 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.3/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4680) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)

Other

Typescript version: 5.6.2 5.7.3

With Node.js v22.11.0 LTS there is an additional warning

(node:6696) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.

which comes from ts-node (see issue TypeStrong/ts-node#2116)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions