Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile TypeScript with "moduleResolution": "bundler" option in v5 #26308

Closed
MasonM opened this issue Mar 30, 2023 · 37 comments · Fixed by #27484
Closed

Unable to compile TypeScript with "moduleResolution": "bundler" option in v5 #26308

MasonM opened this issue Mar 30, 2023 · 37 comments · Fixed by #27484
Labels
E2E Issue related to end-to-end testing topic: typescript Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@MasonM
Copy link

MasonM commented Mar 30, 2023

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 #26148, but was determined to be a separate issue. From looking at the code, I believe the following line is causing this behavior:

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:

if (env.get('CYPRESS_INTERNAL_NO_TYPESCRIPT') === '1' || !projectRoot) {
return null
}

@astone123 astone123 changed the title TypeScript 5 support: "moduleResolution": "bundler" causes errors Unable to compile TypeScript with "moduleResolution": "bundler" option in v5 Mar 31, 2023
@astone123
Copy link
Contributor

@MasonM thanks for including the reproduction, routing this to our e2e team

@astone123 astone123 removed their assignment Mar 31, 2023
MasonM added a commit to MasonM/cypress that referenced this issue Mar 31, 2023
@MasonM
Copy link
Author

MasonM commented Mar 31, 2023

This seems to fix it: 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.js and following the reproduction steps, so I don't know if it'll have any unwanted effects

@lmiller1990
Copy link
Contributor

"moduleResolution": "node" is the default: https://www.typescriptlang.org/docs/handbook/module-resolution.html#module-resolution-strategies. I wonder why that fixes it.

@MasonM
Copy link
Author

MasonM commented Apr 4, 2023

@lmiller1990 Probably because it's getting overridden to "module" by the tsconfig.json in the project

@MasonM
Copy link
Author

MasonM commented Apr 4, 2023

@lmiller1990 That's odd. The reproduction repository doesn't have "allowImportingTsExtensions" at all, so how is it getting that?

@lmiller1990
Copy link
Contributor

lmiller1990 commented Apr 4, 2023

@MasonM I removed my post, I was on the wrong branch. The reproduction does indeed exhibit the issue.

@lmiller1990
Copy link
Contributor

Let's open a PR and see if the test suite passes!

@MasonM
Copy link
Author

MasonM commented Apr 4, 2023

@lmiller1990 Okay, done: #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?

@lmiller1990
Copy link
Contributor

lmiller1990 commented Apr 4, 2023

Actually, this is a little confusing - the issue is that moduleResolution: bundler does not work, so setting moduleResolution: node is the fix?

What is the goal here, exactly? Just to clarify -- If it's just to make it work, this will be just fine. The concern I have is looking at the tsconfig.json, a lot of users might assume moduleResolution: bundler is applied to cypress.config.ts, which it won't be -- we will be overriding that for ts-node, which is what is used to transpile and execute the cypress.config.ts. moduleResolution: bundler will be applied to your Next.js code, which I think is the intention here - the side effect is that it conflicts with our ts-node defaults.

Is this correct? Or do you want to enforce moduleResolution: bundler for the Node.js execution of cypress.config.ts, too? (I don't think that makes too much sense - moduleResolution: bundler is for bundlers, which generally bundler code for browser usage, not Node.js usage).

I think your fix is probably okay, since the goal is just to have things work as you'd generally expect, and I'd say most people expect cypress.config.ts to run in Node.js.

@lmiller1990
Copy link
Contributor

@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.

@MasonM
Copy link
Author

MasonM commented Apr 4, 2023

In my project, we don't have any tests written in TypeScript, only application code. In other words, the mere presence of a tsconfig.json with "moduleResolution": "bundler" triggers this bug, even though we aren't actually using TypeScript with Cypress. That's why setting the environment variable CYPRESS_INTERNAL_NO_TYPESCRIPT=1 is an acceptable workaround for us. It disables TypeScript entirely, but we don't care about TypeScript in our tests.

@MattyBalaam
Copy link

MattyBalaam commented Apr 4, 2023

I wrote the original reproduction because in our codebase we do use TypeScript in a monorepo and we explicitly want to use the bundler option.

The horrible workaround we have at the moment is to put a tsconfig with node moduleResolution in the root of our UI app packages (we are using component testing here not e2e), and then adding extra tsconfig files inside other folders so they use the correct moduleResolution.

@lmiller1990
Copy link
Contributor

lmiller1990 commented Apr 5, 2023

If the goal is what @MattyBalaam wrote, then I am not sure the proposed fix of hard-coding resolution: node is correct. We probably need to make sure all the options are correctly set.

@MattyBalaam to help drive this forward, can you offer insight into why you are choosing to use moduleResolution: bundler for cypress.config, which is just executed (not bundled)? Or do you want to use bundler for everything else (like Vite, etc) and this bug is just a side effect of that?

@MattyBalaam
Copy link

Hi, I'm on holiday at the moment so can't do a big deep dive, but the moduleResolution is set in tsconfig not cypress.config.

This test case is maybe a little inaccurate for our use case which is component tests, and I've just noticed the config here is for e2e (I forked off someone else's example)

We are building out apps using remix which uses esbuild, however out component tests are using a webpack config. The bundler config allows us to export a stricter set of files from our shared UI packages using exports rather than main in our package.json.

@lmiller1990
Copy link
Contributor

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 the cypress.config when we execute it. That will automatically grab tsconfig.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.json and tsconfig.node.json since 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.

@filiptammergard
Copy link

We're also experiencing this problem. Is there a recommended workaround until "moduleResolution": "bundler" is supported?

@lmiller1990
Copy link
Contributor

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.json in 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-node under the hood to execute cypress.config.ts. This also grabs the tsconfig.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.compilerOptions in tsconfig.json that will only be used for your cypress.config.ts transpilation. 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:

{
+  "ts-node": {
+    "compilerOptions": {
+     "module": "es2015",
+      "moduleResolution": "node"
+    }
+ },
  "compilerOptions": {
    "module": "es2015",
    "moduleResolution": "bundler"
  }
}

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.config and 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: bundler for the cypress.config process, 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 when cypress.config.ts is executed. I could be missing something here, though.

@filiptammergard
Copy link

filiptammergard commented Apr 7, 2023

@lmiller1990 Looks like a good workaround!

While it might be more correct, it also adds extra config to maintain and it's not obvious it's related to cypress.config.ts.

I don't see why someone would want to use bundler for cypress.config.ts despite it not being accurate. You just want it to work out of the box, and Cypress knows best what options it needs for that.

I'd love to see #26415 happening to make it possible to keep the project's tsconfig.json unchanged.

But good workaround in the meantime!

@lmiller1990
Copy link
Contributor

#26415 probably still makes sense, main concern is it might break some existing workflows. I'll look into it and see if it can merge as-is, or if it'll need to wait for a major.

@MattyBalaam
Copy link

you can do is specify a ts-node.compilerOptions in tsconfig.json that will only be used for your cypress.config.ts transpilation. Here is how to do that using the OP's reproduction (and it works):

I just took a look at our code again and noticed since I created the original test case here we had also added a ts-node.compilerOptions in our repo to cover running some other ts-node tasks and no longer have the original issue.

@nagash77 nagash77 added Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
@philipp-serfling
Copy link

Any news on that?
The PR seems to be stall?

@lmiller1990
Copy link
Contributor

I don't think anyone is actively working on this. The proper solution doesn't seem clear, either (any recommendation)?

Does #26308 (comment) work for you?

@MasonM
Copy link
Author

MasonM commented Jul 12, 2023

@philipp-serfling The PR is stalled because I can't sign the CLA, so the Cypress team can't accept it. If you can sign the CLA, then feel free to open an identical PR.

@philipp-serfling
Copy link

@MasonM Oh gosh what a pitty.
I could fix it by updating to TypeScript 5.x and VS Code to 1.80.0
See https://stackoverflow.com/questions/76071355/vite-default-template-giving-error-in-vscode-moduleresolution-bundler

@rogerprz
Copy link

I managed to resolve it by running yarn install or npm equivalent 🙄

@lmiller1990
Copy link
Contributor

I think Next.js is broken now too #27448

I will look at picking this one up.

@karlhorky
Copy link
Contributor

karlhorky commented Aug 3, 2023

Thanks @lmiller1990 ! For background, it was changed in vercel/next.js#51957, so broken since a few versions now.

Also, just generally, would be great to get Cypress a bit more stable with TypeScript and ESM, there's a few longer-running bugs which have no good solution to them :) Can feel pretty broken for new users, and we have been suggesting more users switch to Playwright now because of this.

Maybe the leadership would agree with you spending a few days / weeks fixing everything.

@karlhorky
Copy link
Contributor

karlhorky commented Aug 3, 2023

Workaround

For people looking for a temporary workaround, the workaround posted above by @lmiller1990 worked for us too:

Adding the following (old, obsolete) ts-node options for Cypress:

tsconfig.json

{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Bundler"
  },
+ // Old "moduleResolution": "Node" option required for Cypress
+ // https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648
+ //
+ // TODO: Remove when issue is resolved https://github.com/cypress-io/cypress/issues/27448
+ "ts-node": {
+   "compilerOptions": {
+     "module": "ESNext",
+     "moduleResolution": "Node"
+   }
+ }
}

karlhorky added a commit to upleveled/portfolio-cms that referenced this issue Aug 3, 2023
karlhorky added a commit to upleveled/next-starter-peacock that referenced this issue Aug 3, 2023
karlhorky added a commit to upleveled/next-js-portfolio-web that referenced this issue Aug 3, 2023
@himself65
Copy link

Workaround

For people looking for a temporary workaround, the workaround posted above by @lmiller1990 worked for us too:

Adding the following (old, obsolete) ts-node options for Cypress:

tsconfig.json

{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Bundler"
  },
+ // Old "moduleResolution": "Node" option required for Cypress
+ // https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648
+ //
+ // TODO: Remove when issue is resolved https://github.com/cypress-io/cypress/issues/27448
+ "ts-node": {
+   "compilerOptions": {
+     "module": "ESNext",
+     "moduleResolution": "Node"
+   }
+ }
}

This works for me

@nareshbhatia
Copy link

I too was having the same issue, so decided to try with a freshly created Vite app. To my surprise, I was not able to recreate the issue with the fresh Vite app, although it uses "moduleResolution": "bundler". I wonder what is the difference.

This is how I created the Vite app:

npm create vite@latest  # choose options react and typescript
npm install cypress --save-dev
npx cypress open

@Otterwerks
Copy link

Workaround

For people looking for a temporary workaround, the workaround posted above by @lmiller1990 worked for us too:
Adding the following (old, obsolete) ts-node options for Cypress:
tsconfig.json

{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Bundler"
  },
+ // Old "moduleResolution": "Node" option required for Cypress
+ // https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648
+ //
+ // TODO: Remove when issue is resolved https://github.com/cypress-io/cypress/issues/27448
+ "ts-node": {
+   "compilerOptions": {
+     "module": "ESNext",
+     "moduleResolution": "Node"
+   }
+ }
}

This works for me

Also using this workaround

@lmiller1990
Copy link
Contributor

Working on this in #27484

@filiptammergard
Copy link

@lmiller1990 Is this available to use? If so, what version?

@karlhorky
Copy link
Contributor

@filiptammergard from the changelog changes in #27484 it seems that 12.17.5 will include this change, to be released on 29 August 2023:

## 12.17.5

_Released 08/29/2023 (PENDING)_ 

**Bugfixes:**

- Only force CommonJS when running `ts-node` with a `TS_NODE_COMPILER` environment variable, such as when Cypress uses `ts-node` internally. This solves an issue where Cypress' internal `tsconfig` conflicts with properties set in the user's `tsconfig.json` such as `module` and `moduleResolution`. Fixes [#26308](https://github.com/cypress-io/cypress/issues/26308) and [#27448](https://github.com/cypress-io/cypress/issues/27448).

@jennifer-shehane
Copy link
Member

Released in Cypress 13.0.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Aug 29, 2023
@emilyrohrbough emilyrohrbough reopened this Nov 3, 2023
@emilyrohrbough
Copy link
Member

Reopened due to the issue being re-reported and the fix not fully resolving the issue. Please see this comment for workaround suggestions: #27731 (comment).

@jennifer-shehane
Copy link
Member

Going to actually close this as a duplicate of #27731. Please follow that issue if you're encountering this error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E2E Issue related to end-to-end testing topic: typescript Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet