cypress: Unable to compile TypeScript with `"moduleResolution": "bundler"` option in v5
Current behavior
If you have a TypeScript project using the new "moduleResolution": "bundler" setting introduced in TypeScript 5, any attempts to run tests will cause the following error:
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
Desired behavior
Tests run successfully
Test code to reproduce
Courtesy of @MattyBalaam: https://github.com/MattyBalaam/cypress-ts-import
Cypress Version
12.8.1
Node version
18.11.0
Operating System
macOS 12.6
Debug Logs
Expand
$ DEBUG='cypress:*' ./node_modules/.bin/cypress run | tee debug.log
cypress:cli:cli cli starts with arguments ["/opt/homebrew/Cellar/node/18.11.0/bin/node","/Users/mmalone/src/cypress-ts-import/node_modules/.bin/cypress","run"] +0ms
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli:cli program parsing arguments +1ms
cypress:cli:cli running Cypress with args [ Command { _events: [Object: null prototype] { 'option:auto-cancel-after-failures': [Function (anonymous)], 'option:browser': [Function (anonymous)], 'option:ci-build-id': [Function (anonymous)], 'option:component': [Function (anonymous)], 'option:config': [Function (anonymous)], 'option:config-file': [Function (anonymous)], 'option:e2e': [Function (anonymous)], 'option:env': [Function (anonymous)], 'option:group': [Function (anonymous)], 'option:key': [Function (anonymous)], 'option:headed': [Function (anonymous)], 'option:headless': [Function (anonymous)], 'option:no-exit': [Function (anonymous)], 'option:parallel': [Function (anonymous)], 'option:port': [Function (anonymous)], 'option:project': [Function (anonymous)], 'option:quiet': [Function (anonymous)], 'option:record': [Function (anonymous)], 'option:reporter': [Function (anonymous)], 'option:reporter-options': [Function (anonymous)], 'option:spec': [Function (anonymous)], 'option:tag': [Function (anonymous)], 'option:dev': [Function (anonymous)] }, _eventsCount: 23, _maxListeners: undefined, commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], parent: Command { _events: [Object: null prototype], _eventsCount: 1, _maxListeners: undefined, commands: [Array], options: [Array], parent: null, _allowUnknownOption: false, _args: [], rawArgs: [Array], _scriptPath: '/Users/mmalone/src/cypress-ts-import/node_modules/.bin/cypress', _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _actionHandler: null, _executableHandler: false, _executableFile: null, _defaultCommandName: null, _exitCallback: null, _aliases: [], _hidden: false, _helpFlags: '-h, --help', _helpDescription: 'display help for command', _helpShortFlag: '-h', _helpLongFlag: '--help', _hasImplicitHelpCommand: undefined, _helpCommandName: 'help', _helpCommandnameAndArgs: 'help [command]', _helpCommandDescription: 'display help for command', _usage: '<command> [options]', args: [Array], [Symbol(kCapture)]: false }, _allowUnknownOption: false, _args: [], rawArgs: null, _scriptPath: null, _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _actionHandler: [Function: listener], _executableHandler: false, _executableFile: null, _defaultCommandName: null, _exitCallback: null, _aliases: [], _hidden: false, _helpFlags: '-h, --help', _helpDescription: 'display help for command', _helpShortFlag: '-h', _helpLongFlag: '--help', _hasImplicitHelpCommand: 0, _helpCommandName: 'help', _helpCommandnameAndArgs: 'help [command]', _helpCommandDescription: 'display help for command', _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, exit: true, args: [], [Symbol(kCapture)]: false } ] +0ms
cypress:cli:cli variable-length opts parsed { args: [ '/opt/homebrew/Cellar/node/18.11.0/bin/node', '/Users/mmalone/src/cypress-ts-import/node_modules/.bin/cypress', 'run' ], opts: Command { _events: [Object: null prototype] { 'option:auto-cancel-after-failures': [Function (anonymous)], 'option:browser': [Function (anonymous)], 'option:ci-build-id': [Function (anonymous)], 'option:component': [Function (anonymous)], 'option:config': [Function (anonymous)], 'option:config-file': [Function (anonymous)], 'option:e2e': [Function (anonymous)], 'option:env': [Function (anonymous)], 'option:group': [Function (anonymous)], 'option:key': [Function (anonymous)], 'option:headed': [Function (anonymous)], 'option:headless': [Function (anonymous)], 'option:no-exit': [Function (anonymous)], 'option:parallel': [Function (anonymous)], 'option:port': [Function (anonymous)], 'option:project': [Function (anonymous)], 'option:quiet': [Function (anonymous)], 'option:record': [Function (anonymous)], 'option:reporter': [Function (anonymous)], 'option:reporter-options': [Function (anonymous)], 'option:spec': [Function (anonymous)], 'option:tag': [Function (anonymous)], 'option:dev': [Function (anonymous)] }, _eventsCount: 23, _maxListeners: undefined, commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], parent: Command { _events: [Object: null prototype], _eventsCount: 1, _maxListeners: undefined, commands: [Array], options: [Array], parent: null, _allowUnknownOption: false, _args: [], rawArgs: [Array], _scriptPath: '/Users/mmalone/src/cypress-ts-import/node_modules/.bin/cypress', _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _actionHandler: null, _executableHandler: false, _executableFile: null, _defaultCommandName: null, _exitCallback: null, _aliases: [], _hidden: false, _helpFlags: '-h, --help', _helpDescription: 'display help for command', _helpShortFlag: '-h', _helpLongFlag: '--help', _hasImplicitHelpCommand: undefined, _helpCommandName: 'help', _helpCommandnameAndArgs: 'help [command]', _helpCommandDescription: 'display help for command', _usage: '<command> [options]', args: [Array], [Symbol(kCapture)]: false }, _allowUnknownOption: false, _args: [], rawArgs: null, _scriptPath: null, _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _actionHandler: [Function: listener], _executableHandler: false, _executableFile: null, _defaultCommandName: null, _exitCallback: null, _aliases: [], _hidden: false, _helpFlags: '-h, --help', _helpDescription: 'display help for command', _helpShortFlag: '-h', _helpLongFlag: '--help', _hasImplicitHelpCommand: 0, _helpCommandName: 'help', _helpCommandnameAndArgs: 'help [command]', _helpCommandDescription: 'display help for command', _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, exit: true, args: [], [Symbol(kCapture)]: false } } +40ms
cypress:cli parsed cli options {} +43ms
cypress:cli verifying Cypress app +0ms
cypress:cli checking environment variables +0ms
cypress:cli checking if executable exists /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress +2ms
cypress:cli Binary is executable? : true +1ms
cypress:cli binaryDir is /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app +0ms
cypress:cli Reading binary package.json from: /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/package.json +0ms
cypress:cli Found binary version 12.8.1 installed in: /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app +1ms
cypress:cli { verified: true } +2ms
cypress:cli is Verified ? true +1ms
cypress:cli:run processing run options { key: null, spec: null, reporter: null, reporterOptions: null, project: '/Users/mmalone/src/cypress-ts-import' } +0ms
cypress:cli:run --key is not set, looking up environment variable CYPRESS_RECORD_KEY +0ms
cypress:cli:run run to spawn.start args ["--run-project","/Users/mmalone/src/cypress-ts-import"] +0ms
cypress:cli needs to start own Xvfb? false +0ms
cypress:cli spawning, should retry on display problem? false +0ms
cypress:cli spawn args [ '--no-sandbox', '--', '--run-project', '/Users/mmalone/src/cypress-ts-import', '--cwd', '/Users/mmalone/src/cypress-ts-import', '--userNodePath', '/opt/homebrew/Cellar/node/18.11.0/bin/node', '--userNodeVersion', '18.11.0' ] { detached: false, stdio: [ 'inherit', 'inherit', 'pipe' ] } +4ms
cypress:cli spawning Cypress with executable: /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress +1ms
cypress:cli piping child STDERR to process STDERR +1ms
2023-03-30T16:11:06.311Z cypress:snapshot:info Caching 3502, defining 4416 modules! Using cache
2023-03-30T16:11:06.313Z cypress:snapshot:debug initializing packherd require
2023-03-30T16:11:06.439Z cypress:server:appdata path: /Users/mmalone/Library/Application Support/Cypress/cy/production/browsers
2023-03-30T16:11:06.444Z cypress:server:cypress starting cypress with argv [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--', '--run-project', '/Users/mmalone/src/cypress-ts-import', '--cwd', '/Users/mmalone/src/cypress-ts-import', '--userNodePath', '/opt/homebrew/Cellar/node/18.11.0/bin/node', '--userNodeVersion', '18.11.0' ]
2023-03-30T16:11:06.444Z cypress:server:args argv array: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--run-project', '/Users/mmalone/src/cypress-ts-import', '--cwd', '/Users/mmalone/src/cypress-ts-import', '--userNodePath', '/opt/homebrew/Cellar/node/18.11.0/bin/node', '--userNodeVersion', '18.11.0' ]
2023-03-30T16:11:06.445Z cypress:server:args parsed argv options { options: { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, 'run-project': '/Users/mmalone/src/cypress-ts-import', runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0' } }
2023-03-30T16:11:06.447Z cypress:server:args argv parsed: { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0', invokedFromCli: true }
2023-03-30T16:11:06.448Z cypress:server:util:proxy found proxy environment variables {}
2023-03-30T16:11:06.449Z cypress:server:args options { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0', invokedFromCli: true, config: {} }
2023-03-30T16:11:06.449Z cypress:server:args argv options: { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0', invokedFromCli: true, config: {}, projectRoot: '/Users/mmalone/src/cypress-ts-import' }
2023-03-30T16:11:06.449Z cypress:server:cypress from argv [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--run-project', '/Users/mmalone/src/cypress-ts-import', '--cwd', '/Users/mmalone/src/cypress-ts-import', '--userNodePath', '/opt/homebrew/Cellar/node/18.11.0/bin/node', '--userNodeVersion', '18.11.0' ] got options { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0', invokedFromCli: true, config: {}, projectRoot: '/Users/mmalone/src/cypress-ts-import' }
2023-03-30T16:11:06.449Z cypress:server:cypress scaling electron app in headless mode
2023-03-30T16:11:06.459Z cypress:server:appdata path: /Users/mmalone/Library/Application Support/Cypress/cy/production
2023-03-30T16:11:06.483Z cypress:server:cypress starting in mode run with options { _: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/mmalone/src/cypress-ts-import', cwd: '/Users/mmalone/src/cypress-ts-import', userNodePath: '/opt/homebrew/Cellar/node/18.11.0/bin/node', userNodeVersion: '18.11.0', invokedFromCli: true, config: {}, projectRoot: '/Users/mmalone/src/cypress-ts-import' }
2023-03-30T16:11:06.483Z cypress:server:cypress running Electron currently
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.cloudLatestRunUpdateSpecData
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.cloudProjectBySlug
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.cloudProjectsBySlugs
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.cloudSpecByPath
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.cloudViewer
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.pollingIntervals
2023-03-30T16:11:06.525Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for Query.versions
2023-03-30T16:11:06.526Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for CurrentProject.cloudProject
2023-03-30T16:11:06.527Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for RemoteFetchableCloudProjectResult.data
2023-03-30T16:11:06.528Z cypress:graphql:nexusDeferIfNotLoadedPlugin Adding nexusDeferIfNotLoadedPlugin for RemoteFetchableCloudProjectSpecResult.data
2023-03-30T16:11:06.535Z cypress:server:browsers:utils getBrowsers
2023-03-30T16:11:06.535Z cypress:launcher:detect detecting if the following browsers are present [ { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', versionRegex: /Google Chrome (\S+)/m, binary: [ 'google-chrome', 'chrome', 'google-chrome-stable' ], minSupportedVersion: 64 }, { name: 'chromium', family: 'chromium', channel: 'stable', displayName: 'Chromium', versionRegex: /Chromium (\S+)/m, binary: [ 'chromium-browser', 'chromium' ], minSupportedVersion: 64 }, { name: 'chrome', family: 'chromium', channel: 'beta', displayName: 'Chrome Beta', versionRegex: /Google Chrome (\S+) beta/m, binary: 'google-chrome-beta', minSupportedVersion: 64 }, { name: 'chrome', family: 'chromium', channel: 'canary', displayName: 'Canary', versionRegex: /Google Chrome Canary (\S+)/m, binary: 'google-chrome-canary', minSupportedVersion: 64 }, { name: 'firefox', family: 'firefox', channel: 'stable', displayName: 'Firefox', versionRegex: /^Mozilla Firefox ([^\sab]+)$/m, binary: 'firefox', minSupportedVersion: 86, validator: [Function: validator] }, { name: 'firefox', family: 'firefox', channel: 'dev', displayName: 'Firefox Developer Edition', versionRegex: /^Mozilla Firefox (\S+b\S*)$/m, binary: [ 'firefox-developer-edition', 'firefox' ], minSupportedVersion: 86 }, { name: 'firefox', family: 'firefox', channel: 'nightly', displayName: 'Firefox Nightly', versionRegex: /^Mozilla Firefox (\S+a\S*)$/m, binary: [ 'firefox-nightly', 'firefox-trunk' ], minSupportedVersion: 86 }, { name: 'edge', family: 'chromium', channel: 'stable', displayName: 'Edge', versionRegex: /Microsoft Edge (\S+)/im, binary: [ 'edge', 'microsoft-edge' ], minSupportedVersion: 79 }, { name: 'edge', family: 'chromium', channel: 'canary', displayName: 'Edge Canary', versionRegex: /Microsoft Edge.+?(\S*(?= canary)|(?<=canary )\S*)/im, binary: [ 'edge-canary', 'microsoft-edge-canary' ], minSupportedVersion: 79 }, { name: 'edge', family: 'chromium', channel: 'beta', displayName: 'Edge Beta', versionRegex: /Microsoft Edge.+?(\S*(?= beta)|(?<=beta )\S*)/im, binary: [ 'edge-beta', 'microsoft-edge-beta' ], minSupportedVersion: 79 }, { name: 'edge', family: 'chromium', channel: 'dev', displayName: 'Edge Dev', versionRegex: /Microsoft Edge.+?(\S*(?= dev)|(?<=dev )\S*)/im, binary: [ 'edge-dev', 'microsoft-edge-dev' ], minSupportedVersion: 79 } ]
2023-03-30T16:11:06.536Z cypress:server:browsers:utils WebKit is enabled, but there was an error constructing the WebKit browser: { err: Error: Cannot find module 'playwright-webkit' Require stack: - /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/utils.ts at Module._resolveFilename (node:internal/modules/cjs/loader:940:15) at n._resolveFilename (node:electron/js2c/browser_init:249:1105) at resolve (node:internal/modules/cjs/helpers:108:19) at Function.resolve (evalmachine.<anonymous>:1:733924) at N (<embedded>:4649:307730) at Object.I [as getBrowsers] (<embedded>:4649:308565) at b.machineBrowsers (<embedded>:4190:436857) at E._setCurrentProject (<embedded>:4419:35610) at new E (<embedded>:4419:28856) at new I (<embedded>:4419:81094) at N (<embedded>:4721:437435) at s.exports (<embedded>:4721:529803) at <embedded>:4728:2607 at tryCatcher (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23) at Function.<anonymous> (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29) at Object.runElectron (<embedded>:4728:2377) at Object.startInMode (<embedded>:4728:4857) at <embedded>:4728:3945 at tryCatcher (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18) at Promise._fulfill (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:638:18) at Promise._settlePromise (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:582:21) at Promise._settlePromise0 (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18) at Promise._fulfill (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:638:18) at Promise._settlePromise (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:582:21) at Promise._settlePromise0 (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18) at Promise._fulfill (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:638:18) at PromiseArray._resolve (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise_array.js:126:19) at PromiseArray._promiseFulfilled (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise_array.js:144:14) at Promise._settlePromise (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:574:26) at Promise._settlePromise0 (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18) at Promise._fulfill (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:638:18) at /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/nodeback.js:42:21 at <embedded>:1955:88964 { code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/utils.ts' ] } }
2023-03-30T16:11:06.537Z cypress:data-context:sources:GitDataSource config: { isRunMode: true, projectRoot: '/Users/mmalone/src/cypress-ts-import', onError: [Function (anonymous)], onBranchChange: [Function: onBranchChange], onGitInfoChange: [Function: onGitInfoChange], onGitLogChange: [AsyncFunction: onGitLogChange] }
2023-03-30T16:11:06.542Z cypress:scaffold-config:detect Checking for default Cypress config file
2023-03-30T16:11:06.542Z cypress:scaffold-config:detect Detected cypress.config.ts - using TS
2023-03-30T16:11:06.556Z cypress:server:video using ffmpeg from /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/@ffmpeg-installer/darwin-arm64/ffmpeg
2023-03-30T16:11:06.558Z cypress:server:performance-benchmark elapsed time at run mode ready: 249.515ms
2023-03-30T16:11:06.562Z cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/Users/mmalone/src/cypress-ts-import', '--file', '/Users/mmalone/src/cypress-ts-import/cypress.config.ts' ], childOptions: { stdio: 'pipe', cwd: '/Users/mmalone/src/cypress-ts-import', execPath: '/opt/homebrew/Cellar/node/18.11.0/bin/node' } }
2023-03-30T16:11:06.562Z cypress:lifecycle:ProjectConfigIpc found typescript in /Users/mmalone/src/cypress-ts-import
2023-03-30T16:11:06.562Z cypress:lifecycle:ProjectConfigIpc using cjs with --require /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/register_ts_node.js
2023-03-30T16:11:06.563Z cypress:lifecycle:ProjectConfigIpc trigger the load of the file
2023-03-30T16:11:06.594Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Chromium (\S+)/m }
2023-03-30T16:11:06.595Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Chromium (\S+)/m }
2023-03-30T16:11:06.609Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Google Chrome Canary (\S+)/m }
2023-03-30T16:11:06.622Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /^Mozilla Firefox (\S+b\S*)$/m }
2023-03-30T16:11:06.624Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /^Mozilla Firefox (\S+b\S*)$/m }
2023-03-30T16:11:06.631Z cypress:server:register-ts-node executing register_ts_node with args { _: [ '/opt/homebrew/Cellar/node/18.11.0/bin/node', '/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js' ], projectRoot: '/Users/mmalone/src/cypress-ts-import', file: '/Users/mmalone/src/cypress-ts-import/cypress.config.ts' }
2023-03-30T16:11:06.631Z cypress:server:register-ts-node registering ts-node for projectRoot: /Users/mmalone/src/cypress-ts-import and file: /Users/mmalone/src/cypress-ts-import/cypress.config.ts
2023-03-30T16:11:06.631Z cypress:server:ts-node projectRoot path: /Users/mmalone/src/cypress-ts-import
2023-03-30T16:11:06.631Z cypress:server:ts-node registeredFile: /Users/mmalone/src/cypress-ts-import/cypress.config.ts
2023-03-30T16:11:06.631Z cypress:server:plugins resolving typescript with projectRoot '/Users/mmalone/src/cypress-ts-import'
2023-03-30T16:11:06.632Z cypress:server:plugins resolved typescript /Users/mmalone/src/cypress-ts-import/node_modules/typescript/lib/typescript.js
2023-03-30T16:11:06.632Z cypress:server:ts-node typescript path: /Users/mmalone/src/cypress-ts-import/node_modules/typescript/lib/typescript.js
2023-03-30T16:11:06.635Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /^Mozilla Firefox (\S+a\S*)$/m }
2023-03-30T16:11:06.636Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /^Mozilla Firefox (\S+a\S*)$/m }
2023-03-30T16:11:06.645Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge (\S+)/im }
2023-03-30T16:11:06.646Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge (\S+)/im }
2023-03-30T16:11:06.665Z cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
┌─────────┬───────────────────┬──────────────┬─────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
│ (index) │ group │ processCount │ pids │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
├─────────┼───────────────────┼──────────────┼─────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
│ 0 │ 'cypress' │ 1 │ '60449' │ 87.7 │ 87.7 │ 313.66 │ 313.66 │ 313.66 │
│ 1 │ 'other' │ 1 │ '60450' │ 0 │ 0 │ 3.11 │ 3.11 │ 3.11 │
│ 2 │ 'electron-shared' │ 1 │ '60451' │ 0 │ 0 │ 0.53 │ 0.53 │ 0.53 │
│ 3 │ 'TOTAL' │ 3 │ '-' │ 87.7 │ 87.7 │ 317.3 │ 317.3 │ 317.3 │
└─────────┴───────────────────┴──────────────┴─────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘
2023-03-30T16:11:06.666Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= canary)|(?<=canary )\S*)/im }
2023-03-30T16:11:06.666Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= canary)|(?<=canary )\S*)/im }
2023-03-30T16:11:06.678Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= beta)|(?<=beta )\S*)/im }
2023-03-30T16:11:06.679Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= beta)|(?<=beta )\S*)/im }
2023-03-30T16:11:06.694Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= dev)|(?<=dev )\S*)/im }
2023-03-30T16:11:06.696Z cypress:launcher:linux Could not extract version from stdout using regex: { stdout: '', versionRegex: /Microsoft Edge.+?(\S*(?= dev)|(?<=dev )\S*)/im }
2023-03-30T16:11:06.697Z cypress:server:browsers:utils found browsers { browsers: [ { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '111.0.5563.146', path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', minSupportedVersion: 64, majorVersion: '111' }, { name: 'chrome', family: 'chromium', channel: 'beta', displayName: 'Chrome Beta', version: '112.0.5615.49', path: '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta', minSupportedVersion: 64, majorVersion: '112' }, { name: 'firefox', family: 'firefox', channel: 'stable', displayName: 'Firefox', version: '111.0.1', path: '/Applications/Firefox.app/Contents/MacOS/firefox', minSupportedVersion: 86, majorVersion: '111' } ] }
2023-03-30T16:11:06.735Z cypress:server:ts-node registering project TS with options { compiler: '/Users/mmalone/src/cypress-ts-import/node_modules/typescript/lib/typescript.js', compilerOptions: { module: 'commonjs', preserveValueImports: false }, dir: '/Users/mmalone/src/cypress-ts-import', transpileOnly: true }
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
at createTSError (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311:16)
at reportTSError (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:314:23)
at /Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:686:17
at Object.compile (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:743:35)
at Module.m._compile (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:856:36)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.require.extensions.<computed> [as .js] (/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
diagnosticCodes: [ 5095 ]
}
2023-03-30T16:11:16.868Z cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
┌─────────┬───────────────────┬──────────────┬────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
│ (index) │ group │ processCount │ pids │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
├─────────┼───────────────────┼──────────────┼────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
│ 0 │ 'cypress' │ 1 │ '60449' │ 1.4 │ 44.55 │ 320.69 │ 317.17 │ 320.69 │
│ 1 │ 'electron-shared' │ 2 │ '60451, 60691' │ 0.5 │ 0.25 │ 80.84 │ 40.69 │ 80.84 │
│ 2 │ 'other' │ 1 │ '60772' │ 0 │ 0 │ 2.27 │ 2.69 │ 3.11 │
│ 3 │ 'TOTAL' │ 4 │ '-' │ 1.9 │ 44.8 │ 403.8 │ 360.55 │ 403.8 │
└─────────┴───────────────────┴──────────────┴────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘
Other
This was originally reported in https://github.com/cypress-io/cypress/issues/26148, but was determined to be a separate issue. From looking at the code, I believe the following line is causing this behavior: https://github.com/cypress-io/cypress/blob/e6b2466f7b219a86da46c1ac720432ef75193ca4/packages/server/lib/plugins/child/ts_node.js#L25
There is a workaround, but it only works if you don’t have any tests written in TypeScript: set the environment variable CYPRESS_INTERNAL_NO_TYPESCRIPT=1 to disable TypeScript entirely: https://github.com/cypress-io/cypress/blob/74ada1157c1bf1b184e09873edb6868ae7a67f43/packages/server/lib/util/resolve.js#L12-L14
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 4
- Comments: 37 (19 by maintainers)
Commits related to this issue
- Fix TypeScript 5 bug #26308 — committed to MasonM/cypress by MasonM a year ago
- Use old "module" option for Cypress Ref: https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648 — committed to upleveled/portfolio-cms by karlhorky a year ago
- Use old moduleResolution for Cypress Ref: https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648 — committed to upleveled/next-starter-peacock by karlhorky a year ago
- Use old moduleResolution for Cypress Ref: https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648 — committed to upleveled/next-js-portfolio-web by karlhorky a year ago
- Use old moduleResolution for Cypress Ref: https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648 — committed to upleveled/next-portfolio-dev by karlhorky a year ago
Oh you know what, I think I do have a good solution. Let me clarify, to make sure it’s clear what’s going on.
Most users want the
tsconfig.jsonin their project for use with their bundler (webpack, Vite) or framework (Next.js, using webpack, SvelteKit, with Vite, etc…). These are bundlers, so using the new moduleResolution: bundler makes sense.The side effect is Cypress uses
ts-nodeunder the hood to executecypress.config.ts. This also grabs thetsconfig.json. Most likely, users do not want to use moduleResolution: bundler here - it’s not bundling any code, just transpiling the TS to JS to execute in a one-off fashion.Assume this use case, what you can do is specify a
ts-node.compilerOptionsintsconfig.jsonthat will only be used for yourcypress.config.tstranspilation. Here is how to do that using the OP’s reproduction (and it works):https://github.com/MattyBalaam/cypress-ts-import/pull/1/files
For completeness, the code:
cc @filiptammergard @MattyBalaam @MasonM - this should help! I think this is more correct, actually. You have complete control over how both TS pipelines (your Node.js for
cypress.configand for your bundler) behave.https://github.com/cypress-io/cypress/pull/26415/files is still probably relevant and makes sense, we can get this PR ready, too. The only non-solved use case is actually using
moduleResolution: bundlerfor thecypress.configprocess, but I really don’t think many people want this - you’d be using a moduleResolution strategy that doesn’t really line up with what is actually happening whencypress.config.tsis executed. I could be missing something here, though.Working on this in #27484
Workaround
For people looking for a temporary workaround, the workaround posted above by @lmiller1990 worked for us too:
Adding the following (old, obsolete)
ts-nodeoptions for Cypress:tsconfig.json@filiptammergard from the changelog changes in #27484 it seems that 12.17.5 will include this change, to be released on 29 August 2023:
This works for me
Sure no problem - no rush on this.
I think there’s a bit of confusion here - if the project has
cypress.config.ts(not the TS extension) we will use typescript to transpile thecypress.configwhen we execute it. That will automatically grabtsconfig.json- I don’t think this is obvious at all to the majority of users, which is why there is a lot of confusion.A lot of projects I’ve seen have started doing
tsconfig.jsonandtsconfig.node.jsonsince they use TS on the back and front ends.I think we should come up with a better general solution so this entire process is less confusing. When you’ve got some bandwidth, we can look to explore some solutions. I wonder if we can adopt esbuild too - it’s fast, and a lot more simple to use.
I think Next.js is broken now too https://github.com/cypress-io/cypress/issues/27448
I will look at picking this one up.
@MasonM right, I see - once we clarify the goal here, I can force commit with and override your contribution (and CLA requirement). I can still tag you in the commit message to give some attribution.
@lmiller1990 Okay, done: https://github.com/cypress-io/cypress/pull/26415
Seems the tests aren’t running, probably because I didn’t sign the CLA. But I can’t do that without permission from my employer, and that process generally takes several months, so would you or @MattyBalaam mind entering the PR instead?
@MasonM I removed my post, I was on the wrong branch. The reproduction does indeed exhibit the issue.
This seems to fix it: https://github.com/cypress-io/cypress/compare/develop...MasonM:cypress:fix-26308
But I only tested by manually applying this change to
/Users/mmalone/Library/Caches/Cypress/12.8.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/ts_node.jsand following the reproduction steps, so I don’t know if it’ll have any unwanted effects