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

Error message printed to the console: Couldn't find tsconfig.json. tsconfig-paths will be skipped #22273

Open
ptarczon opened this issue Jun 13, 2022 · 37 comments
Labels
E2E Issue related to end-to-end testing Reproducible Can be reproduced stage: needs investigating Someone from Cypress needs to look at this type: bug

Comments

@ptarczon
Copy link

ptarczon commented Jun 13, 2022

Current behavior

Similar issue as this but with version 10.1.0
Using a tsconfig.json in the cypress directory according to the documentation
Run the command npx cypress open
The output displays:
Couldn't find tsconfig.json. tsconfig-paths will be skipped

Moving tsconfig.json to the root of the project helped but then another error was printed:

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

Adding "baseUrl": "./", to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed in cypress.config.ts

Desired behavior

No such error printed to the console.

Test code to reproduce

mkdir sample-project
cd sample-project
npm init --force
npm i --save-dev cypress typescript
npx cypress open --e2e --browser chrome
click continue button
quit cypress runner
cd cypress
touch tsconfig.json // paste contents in this file
cd ../
npx cypress open

contents of tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"]
  },
  "include": ["**/*.ts"]
}

Logs:

❯ mkdir sample-project
❯ cd sample-project
❯ npm init --force
npm WARN using --force Recommended protections disabled.
Wrote to /Users/piotrtarczon/VSCprojects/sample-project/package.json:

{
  "name": "sample-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


❯ npm i --save-dev cypress typescript

added 166 packages, and audited 167 packages in 1s

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npx cypress open --e2e --browser chrome
objc[34125]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa4ead6318) and /Users/piotrtarczon/Library/Caches/Cypress/10.1.0/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x111c759c8). One of the two will be used. Which one is undefined.
Couldn't find tsconfig.json. tsconfig-paths will be skipped
GET /__/ 200 7.732 ms - -
GET /__/assets/index.0128a075.css 200 5.049 ms - -
GET /__/assets/index.a96bfe29.js 200 70.632 ms - -
GET /chrome-variations/seed?osname=mac&channel=stable&milestone=102 304 673.540 ms - -
POST /ListAccounts?gpsia=1&source=ChromiumBrowser&json=standard 200 690.160 ms - -
GET /__cypress/runner/cypress_runner.css 200 3.085 ms - -
GET /__cypress/runner/cypress_runner.js 200 5.155 ms - -
GET /__/assets/Specs.ec514639.js 200 1.491 ms - 479
GET /__/assets/Index.8f76e9d7.css 200 4.905 ms - -
GET /__/assets/add-large_x16.34ef0540.js 200 7.495 ms - 753
GET /__/assets/Index.2108bd02.js 200 6.425 ms - -
GET /__/assets/SpecPatterns.5862fb95.js 200 9.320 ms - -
GET /__/assets/warning_x16.d9896e59.js 200 25.384 ms - -
GET /__/assets/CreateSpecModal.7b82dc44.js 200 15.439 ms - -
GET /__/assets/settings_x16.2429c71a.js 200 27.289 ms - -
GET /__/assets/cypress_s.29af549a.png 200 7.971 ms - 4425
GET /__/assets/chrome.1b5cb774.svg 200 1.342 ms - -
GET /__/assets/electron.fb07f5cc.svg 200 1.916 ms - -
GET /__/assets/firefox.9be61e66.svg 200 2.545 ms - -
GET /__cypress/runner/favicon.ico?v2 404 0.973 ms - 136
GET /__cypress/assets/favicon.png?v2 404 1.132 ms - 136
POST /v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw 200 766.750 ms - -
❯ cd cypress
❯ touch tsconfig.json
❯ cd ../
❯ npx cypress open
objc[34991]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa4ead6318) and /Users/piotrtarczon/Library/Caches/Cypress/10.1.0/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x1124469c8). One of the two will be used. Which one is undefined.
Couldn't find tsconfig.json. tsconfig-paths will be skipped

Cypress Version

10.1.10

Other

No response

@jennifer-shehane
Copy link
Member

Maybe duplicate of this: #21805

@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Jun 13, 2022
@rachelruderman
Copy link
Contributor

@ptarczon thank you for reporting this issue!

To answer this question...

Adding "baseUrl": "./", to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed in cypress.config.ts

Both TypeScript and Cypress have a property called baseUrl in their respective config files, but they're different concepts 😸

Cypress baseUrl: "URL used as prefix for cy.visit() or cy.request() command's URL."

TypeScript baseUrl: "Lets you set a base directory to resolve non-absolute module names."

@rachelruderman
Copy link
Contributor

This issue covers two topics:

  1. When TS is installed but no tsconfig.json is present, it logs Couldn't find tsconfig.json. tsconfig-paths will be skipped. Do not show tsconfig.json warning in terminal for TS projects without tsconfig.json #21805 is requesting that log be suppressed since nothing is necessarily wrong
  2. When TS is installed and tsconfig.json is added to the cypress root in accordance with the documentation, it logs Couldn't find tsconfig.json. tsconfig-paths will be skipped

I've created a repo here to reproduce the issue

@oliverlockwood
Copy link

I'm facing issue #2 as @rachelruderman described it. I have a tsconfig.json - I believe in the right place! - and want it to be used, but the error message appears.
My E2Es seem to run OK so it might be benign, if a little disconcerting.

@dante01yoon
Copy link

dante01yoon commented Jul 1, 2022

I'm facing this issue too. I build docker image based on cypress/browsers:node14.17.6-slim-chrome100-ff99-edge, error occurred right after print cypress report, my pipeline assumes whole process is failed.

@ShadowLNC
Copy link

Adding "baseUrl": "./", to the compilerOptions made error disappear

This only seems to apply if tsconfig.json is in the root, as opposed to the Cypress folder.

If I put tsconfig.json in the Cypress folder (like Rachel's example and like the docs specify) then it seems to be ignored. Commenting or adding baseUrl has no effect on the error message.

If I put tsconfig.json in the root, then the error is suppressed. If I comment out my baseUrl declaration while tsconfig.json is in the root, I get the following:

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

Has Cypress 10 changed the expected location of tsconfig.json?

@h2oearth
Copy link

Why CY makes mandatory this tsconfig.json?. We do not use TS in some of our projects and CY keeps complaining about such file!

@mschile mschile added triage and removed triage labels Aug 18, 2022
@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Sep 11, 2022

I am seeing the warning message "Couldn't find tsconfig.json. tsconfig-paths will be skipped" on Cypress 10.7.0 after running npm install cypress@10.7.0 from a project which was previously running Cypress 9.7.0. The Cypress test specs are purely JavaScript. There are no *.ts files in the Cypress folders.

On the first run of npx cypress open on Cypress 10.7.0 the warning message "Couldn't find tsconfig.json. tsconfig-paths will be skipped" is displayed, before any Cypress 10 migration steps in the Cypress console have been carried out.

npx cypress open run with Cypress 9.7.0 does not output this message. I did however confirm that npx cypress open run with Cypress 10.0.0 also produces the warning message.

The warning message does not seem to affect the successful running of E2E tests written in JavaScript (*.js).

The problem is reproducible on Windows 10 and Windows 11 with Cypress 10.7.0. On Ubuntu 20.04 / 22.04 I could only reproduce with Cypress 10.0.0, not with Cypress 10.11.0.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Sep 12, 2022

Following on from #22273 (comment):

Uninstalling npm package browser-sync caused the warning message "Couldn't find tsconfig.json. tsconfig-paths will be skipped" on Cypress 10.7.0 to go away. browser-sync pulls in the npm package TypeScript and in my case uninstalling browser-sync also uninstalled typescript.

Before uninstall:

$ npm ls typescript
└─┬ browser-sync@2.27.10
  └─┬ browser-sync-client@2.27.10
    └── typescript@4.9.3

With no typescript installed there was then no warning message.

Unfortunately for me this is not a solution, only a helpful troubleshooting step.

As @h2oearth mentioned, I don't think that this warning should appear if the Cypress test specs do not include any TypeScript modules. The presence of an installed npm TypeScript module on its own should not trigger the warning.

If this should be recorded as a separate issue, please let me know.

Edit: Confirmed that issue still exists in Cypress 12.2.0, however I am now having difficulty to get the issue to reproduce reliably 🙁.


Repro steps:

npm install -D cypress@latest
npx cypress open
Click E2E Testing
Click Continue
exit Cypress

npx cypress open
note no error
exit Cypress

npm install -D browser-sync
npx cypress open
"Couldn't find tsconfig.json. tsconfig-paths will be skipped"

Lisa-V-Sau added a commit to DFE-Digital/prepare-academy-conversions that referenced this issue Oct 6, 2022
Cypress grep:
- Cypress 10.0^ dependency
- Grep Module import to /plugins/index.js & /support/e2e.js
- Tags in use: @dev,@ stage, @integration
- For more recipes: https://github.com/cypress-io/cypress-grep

Cypress upgrade:
- Cypress package version: 10.9.0
- Folder where tests live is renamed: from 'integration', to 'e2e'
- Test files renamed: from '.spec.js', now '.cy.js'
- Support files renamed from: /support/index.js, now support/e2e.js
- Cypress config files changed: from cypress.json, now cypress.config.ts
- Latest changes: https://docs.cypress.io/guides/references/changelog

Cypress 10.9.0 known issues:
- Unable to run all tests at once via Cypress GUI: cypress-io/cypress#21628
- Error Log each time tests run in terminal: cypress-io/cypress#22273

README:
- grep run command
- grep recipes
Lisa-V-Sau added a commit to DFE-Digital/prepare-academy-conversions that referenced this issue Oct 7, 2022
* Task 108196: Cypress Tags

Cypress grep:
- Cypress 10.0^ dependency
- Grep Module import to /plugins/index.js & /support/e2e.js
- Tags in use: @dev,@ stage, @integration
- For more recipes: https://github.com/cypress-io/cypress-grep

Cypress upgrade:
- Cypress package version: 10.9.0
- Folder where tests live is renamed: from 'integration', to 'e2e'
- Test files renamed: from '.spec.js', now '.cy.js'
- Support files renamed from: /support/index.js, now support/e2e.js
- Cypress config files changed: from cypress.json, now cypress.config.ts
- Latest changes: https://docs.cypress.io/guides/references/changelog

Cypress 10.9.0 known issues:
- Unable to run all tests at once via Cypress GUI: cypress-io/cypress#21628
- Error Log each time tests run in terminal: cypress-io/cypress#22273

README:
- grep run command
- grep recipes

* Task 108196: Cypress Tags

- updates to README

* Task 108196: Cypress Tags - fix typo

- Fix typo on README
Lisa-V-Sau added a commit to DFE-Digital/prepare-academy-transfers that referenced this issue Oct 10, 2022
Cypress grep:
- Cypress 10.0^ dependency
- Grep Module import to /plugins/index.js & /support/e2e.js
- Tags in use: @dev,@ stage, @integration
- For more recipes: https://github.com/cypress-io/cypress-grep

Cypress upgrade:
- Cypress package version: 10.9.0
- Folder where tests live is renamed: from 'integration', to 'e2e'
- Test files renamed: from '.spec.js', now '.cy.js'
- Support files renamed from: /support/index.js, now support/e2e.js
- Cypress config files changed: from cypress.json, now cypress.config.ts
- Latest changes: https://docs.cypress.io/guides/references/changelog

Cypress 10.9.0 known issues:
- Unable to run all tests at once via Cypress GUI: cypress-io/cypress#21628
- Error Log each time tests run in terminal: cypress-io/cypress#22273

README:
- grep run command
- grep recipes

Files removed:
- test examples
- Unnecessary
@nagash77 nagash77 added E2E Issue related to end-to-end testing and removed E2E-core labels Nov 8, 2022
@MikeMcC399
Copy link
Contributor

@segevfiner

Newer tsconfig-paths changed the way this is done so this error shouldn't happen anymore if Cypress will upgrade.

Do you know what the minimum version of tsconfig-paths would be needed to resolve the issue in Cypress? I can see that the latest version is 4.1.0 whereas for instance Cypress seems to be using 3.10.1:

"tsconfig-paths": "3.10.1",

@segevfiner
Copy link

4.0.0+ but 4.1.0 fixed some bugs. They published a changelog.

@MikeMcC399

This comment was marked as outdated.

@MikeMcC399

This comment was marked as outdated.

@vsDizzy
Copy link

vsDizzy commented Mar 14, 2023

This is bad experience when I'm following the cookbook and facing this error.
Please fix either the documentation or the code.

@yabab
Copy link

yabab commented Mar 14, 2023

This annoyed me so much I actually went and created another tsconfig.json in the project's root (used it to store general settings not directly related to Cypress and set a baseUrl) and used the tsconfig.json located in the cypress/ folder to extend the one in the project's root. Message no longer appears and checked that Cypress is correctly using data from both files.

@shaharb-hs
Copy link

Also encountered. Why not fix it? It's been open since June 2022 and still getting attention

@shoaibshebi
Copy link

Just uninstalled the cypress. Deleted the file and folders it generated and then again run the command to install cypress.
Then I run just put cypress in my pakcage.json file of react project created by CRA:

"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject",
"cypress": "cypress open"
},
and run "npm run cypress" in the terminal and cypress just ran, and them I click on the component testing and then cypress just setup all the files and folders on my project automatically, and all went good
Thanks @FerdinandFidel

@NickHeiner
Copy link

This error message is confusing. It's not clear what the implication is. My test seems to run fine.

@temrb
Copy link

temrb commented Apr 30, 2023

after adding "baseUrl": "." in tsconfig from comments warning dissappears. I'm guessing that is the issue

@segevfiner
Copy link

It's a limitation of an old version of tsconfig-paths. It is no longer needed in >4 should cypress finally update.

@Raihanhn
Copy link

Raihanhn commented May 3, 2023

After run "npx cypress open" getting this error

C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\core\build\src\platform\node\environment.js:27
HOSTNAME: os.hostname(),
^
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_gethostname returned ENOSYS (function not implemented)
at getEnv (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\core\build\src\platform\node\environment.js:27:22)
at Object. (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\sdk-trace-base\build\src\config.js:25:31)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Object.require.extensions. [as .js] (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules\ts-node\dist\index.js:851:20)
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 Object. (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\sdk-trace-base\build\src\utility.js:19:18) {
code: 'ERR_SYSTEM_ERROR',
info: {
errno: -4054,
code: 'ENOSYS',
message: 'function not implemented',
syscall: 'uv_os_gethostname'
},
errno: [Getter/Setter],
syscall: [Getter/Setter]
}

@MikeMcC399

This comment was marked as off-topic.

@Raihanhn
Copy link

Raihanhn commented May 3, 2023

I am using nodejs version 16.

@MikeMcC399

This comment was marked as off-topic.

@Raihanhn
Copy link

Raihanhn commented May 3, 2023

Windows 7, 64-bit

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented May 3, 2023

@Raihanhn

The Cypress.io team will need to check, however https://learn.microsoft.com/en-us/lifecycle/products/windows-7 shows that Microsoft no longer supports this version of Microsoft Windows.

Your problem is indeed a completely separate issue from the one you have tagged on to here.

@Raihanhn
Copy link

Raihanhn commented May 3, 2023

Okay.Thanks for your info.

@Churs82
Copy link

Churs82 commented May 11, 2023

After run "npx cypress open" getting this error

C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\core\build\src\platform\node\environment.js:27 HOSTNAME: os.hostname(), ^ SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_gethostname returned ENOSYS (function not implemented) at getEnv (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\core\build\src\platform\node\environment.js:27:22) at Object. (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\sdk-trace-base\build\src\config.js:25:31) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Object.require.extensions. [as .js] (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules\ts-node\dist\index.js:851:20) 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 Object. (C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\sdk-trace-base\build\src\utility.js:19:18) { code: 'ERR_SYSTEM_ERROR', info: { errno: -4054, code: 'ENOSYS', message: 'function not implemented', syscall: 'uv_os_gethostname' }, errno: [Getter/Setter], syscall: [Getter/Setter] }

The workaround is to go to C:\Users\user\AppData\Local\Cypress\Cache\12.11.0\Cypress\resources\app\node_modules@opentelemetry\core\build\src\platform\node\environment.js (you can click it in VSC console) and change os.hostname() to hardcoded name of your machine .
Node.js above 14 use new version of libuv which is not compatible with windows 7 . So you can install modern node.js with ignorance of OS requirements but you cant use os.hostname() in your code or in libraries.

@edudelta
Copy link

I'm facing same issue running

  • Windows 10 Pro
  • Cypress 12.14.0
  • Node 18.16.0
  • Typescript 5.1.3

cypress/tsconfig.json exists but "Couldn't find tsconfig.json. tsconfig-paths will be skipped"

@yassinesos
Copy link

I performed the following steps, and the error message disappeared:

Navigate to the AppData\Roaming\Cypress\cy\production\projects directory.
Locate your project folder within this directory.
Delete the project folder from the directory.
Attempt to open Cypress again and see if the issue is resolved.

@theTestingApproach
Copy link

theTestingApproach commented Jul 21, 2023

This is still happening in 12.12.0
my tsconfig.json file is in my cypress folder.
I am getting "Unresolved function or method describe() " in all my cypress tests.
And i get this too in the pipeline:
Couldn't find tsconfig.json. tsconfig-paths will be skipped
Any solution so far for this apart placing the tsconfig.json in the root of the project

@jamaybyrone
Copy link

Not sure if this helps anyone, but for me changing:
"moduleResolution": "bundler"

in tsconfig
to:
"moduleResolution": "node"

resolved the issue

@JackPaulssen
Copy link

I'm seeing the same error, "Couldn't find tsconfig.json. tsconfig-paths will be skipped" having installed Typescript globally on my machine for a different project, despite not using Typescript on this specific Cypress project.

Unsure how to resolve.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this Reproducible Can be reproduced labels Dec 21, 2023
@only4arunkumar
Copy link

Hello , for me the issue get resolved when i launch cypress using sudo command on mac.
sudo npm i -f
<>
sudo npx cypress open

@ddnexus
Copy link

ddnexus commented Jun 5, 2024

Simple workaround: use a minimal workspace.

Create a container dir in your project (sort of a sub-project that just runs the cypress tests) and put inside it: the cypress dir, a minimal package.json (no dependencies in it, so no node_modules dir), the cypress.config.ts, the tsconfig.json, etc.

It works and it's tidier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Reproducible Can be reproduced stage: needs investigating Someone from Cypress needs to look at this type: bug
Projects
None yet
Development

No branches or pull requests