cypress icon indicating copy to clipboard operation
cypress copied to clipboard

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

Open ptarczon opened this issue 2 years ago • 35 comments

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

ptarczon avatar Jun 13 '22 08:06 ptarczon

Maybe duplicate of this: https://github.com/cypress-io/cypress/issues/21805

jennifer-shehane avatar Jun 13 '22 14:06 jennifer-shehane

@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 avatar Jun 14 '22 17:06 rachelruderman

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

rachelruderman avatar Jun 14 '22 17:06 rachelruderman

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.

oliverlockwood avatar Jun 16 '22 06:06 oliverlockwood

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.

dante01yoon avatar Jul 01 '22 06:07 dante01yoon

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?

ShadowLNC avatar Jul 07 '22 01:07 ShadowLNC

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

h2oearth avatar Jul 25 '22 12:07 h2oearth

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 [email protected] 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 avatar Sep 11 '22 13:09 MikeMcC399

Following on from https://github.com/cypress-io/cypress/issues/22273#issuecomment-1242963302:

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
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

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"

MikeMcC399 avatar Sep 12 '22 07:09 MikeMcC399

I'm not sure if i'm doing this right but using @rachelruderman post:

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

I have 2 tsconfig.json files. One in the root of my project and one in the /cypress folder. I added baseUrl to the one in the root folder and the error goes away. the tsconfig.json in the cypress folder is just as the documentation said it should be:

/tsconfig.json

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true,
    "baseUrl": "."
  }
}

/cypress/tsconfig.json

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

Hope This helps someone

jasondavis87 avatar Nov 10 '22 04:11 jasondavis87

Newer tsconfig-paths changed the way this is done so this error shouldn't happen anymore if Cypress will upgrade. (It handles "baseDir": undefined properly instead of requiring it)

segevfiner avatar Nov 20 '22 16:11 segevfiner

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

https://github.com/cypress-io/cypress/blob/bf6a52ab3d6b674985042c2871be4f36ade7652a/packages/server/package.json#L188

MikeMcC399 avatar Nov 21 '22 16:11 MikeMcC399

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

segevfiner avatar Nov 21 '22 17:11 segevfiner

  • I have logged a new issue #25335 so that this can perhaps be looked at separately.

MikeMcC399 avatar Jan 03 '23 11:01 MikeMcC399

@segevfiner

Your suggestion (which I quoted) has been picked up in https://github.com/cypress-io/cypress/issues/25335#issuecomment-1371268783, so hopefully there will be some further movement on this issue soon.

  • Edit: I closed #25335 since the issue was no longer reproducible with browser-sync latest version.

MikeMcC399 avatar Jan 04 '23 19:01 MikeMcC399

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

vsDizzy avatar Mar 14 '23 01:03 vsDizzy

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.

yabab avatar Mar 14 '23 04:03 yabab

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

shaharb-hs avatar Mar 24 '23 13:03 shaharb-hs

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

shoaibshebi avatar Apr 13 '23 17:04 shoaibshebi

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

NickHeiner avatar Apr 14 '23 20:04 NickHeiner

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

temrb avatar Apr 30 '23 04:04 temrb

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

segevfiner avatar Apr 30 '23 06:04 segevfiner

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] }

Raihanhn avatar May 03 '23 10:05 Raihanhn

@Raihanhn

You problem does not seem to be related to the original issue "Error message printed to the console: Couldn't find tsconfig.json. tsconfig-paths will be skipped". You may need to open a new issue.

Are you using one of the Node.js versions supported by Cypress? (14) 16, 18 or later? Which type of host are you running under?

MikeMcC399 avatar May 03 '23 11:05 MikeMcC399

I am using nodejs version 16.

Raihanhn avatar May 03 '23 11:05 Raihanhn

@Raihanhn Could you give the name and version of your operating system as well?

MikeMcC399 avatar May 03 '23 11:05 MikeMcC399

Windows 7, 64-bit

Raihanhn avatar May 03 '23 11:05 Raihanhn

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

MikeMcC399 avatar May 03 '23 12:05 MikeMcC399

Okay.Thanks for your info.

Raihanhn avatar May 03 '23 12:05 Raihanhn

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.

Churs82 avatar May 11 '23 05:05 Churs82