question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version 10: Your configFile is invalid cypress.config.ts

See original GitHub issue

Current behavior

I can’t get by this screen after the cypress UI pops up, everything seemed fine until the config->.ts step.

image

Error
Your configFile is invalid: C:\Github\Project\cypress.config.ts

It threw an error when required, check the stack trace below:

[Stack trace](http://localhost:22331/__launchpad/index.html#)
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:371:5)
    at throwIfUnsupportedURLProtocol (node:internal/modules/esm/resolve:1033:11)
    at defaultResolve (node:internal/modules/esm/resolve:1103:3)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ESMLoader.import (node:internal/modules/esm/loader:332:22)
    at importModuleDynamically (node:internal/modules/cjs/loader:1042:29)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
    at importModuleDynamically (node:vm:381:46)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
    at loadFile (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:126:9)
    at EventEmitter. (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:136:38)
    at EventEmitter.emit (node:events:520:28)
    at EventEmitter.emit (node:domain:475:12)
    at process. (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:33:22)
    at process.emit (node:events:520:28)
import { defineConfig } from 'cypress'

export default defineConfig({
  projectId: 'nqoyvw',
  viewportWidth: 1480,
  viewportHeight: 1260,
  video: false,
  videosFolder: 'cypress/videos',
  screenshotsFolder: 'cypress/screenshots',
  pageLoadTimeout: 60000,
  requestTimeout: 45000,
  responseTimeout: 45000,
  experimentalStudio: true,
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      return require('./cypress/plugins/index.js')(on, config)
    },
    baseUrl: 'https://dev.project.ca',
    specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
  },
})

Debug logs

No response

Cypress Version

10

Package Manager

npm

Operating system

Windows

Other

Node: v16.14.0 tsc: Version 4.0.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sitefinitystevecommented, Jun 1, 2022

Hmm, no, now I’m getting

Your configFile is invalid: C:\Github\Medportal\cypress.config.ts

It threw an error when required, check the stack trace below:

[Stack trace](http://localhost:23407/__launchpad/index.html#)
C:\Github\Project\cypress.config.ts:3
export default defineConfig({
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadFile (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:102:14)
    at EventEmitter. (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:136:38)
    at EventEmitter.emit (node:events:520:28)
    at EventEmitter.emit (node:domain:475:12)
    at process. (C:\Users\steve\AppData\Local\Cypress\Cache\10.0.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:33:22)
    at process.emit (node:events:520:28)
    at process.emit (node:domain:475:12)
    at emit (node:internal/child_process:938:14)
    ```
0reactions
qntmcommented, Jun 2, 2022

OK so first of all it looks as if the specific ERR_UNSUPPORTED_ESM_URL_SCHEME stack trace I was seeing only appears with Cypress 10.0.0. In 10.0.1 I believe this behaviour may have been slightly altered, and I now see a different error. Specifically, this issue. I will take a look at that issue and see if I can add anything useful there instead. This issue can stay closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid configFile (Cypress 10.0) - cannot find module
I've followed the new documentation, however Cypress is stating my file is invalid. "Error: Cannot find module 'cypress'". Here's the config I'm ...
Read more >
Configuration - Cypress Documentation
This guide is for Cypress 10 and the new JavaScript configuration file format. If you are on an older version of Cypress that...
Read more >
Cypress: Migrating from 9.x to 10.x manually - Medium
You might currently have cypress.json as your config file. This has been now replaced with cypress.config.js or cypress.config.ts .
Read more >
Specify Cypress configuration files - BrowserStack
Learn how to specify a Cypress configuration file for your tests run on ... Using the --cypress-config-file CLI parameter ... Cypress v10; Cypress...
Read more >
Configurations in Cypress and How to Disable Default ...
What are default configurations provided by Cypress? ... environment variables, node version, the folder path from where it is reading all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found