Open ptarczon opened 2 years ago
Maybe duplicate of this: https://github.com/cypress-io/cypress/issues/21805
@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."
This issue covers two topics:
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 wrongtsconfig.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'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.
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.
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?
Why CY makes mandatory this tsconfig.json
?. We do not use TS in some of our projects and CY keeps complaining about such file!
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.
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
└─┬ 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"
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:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"baseUrl": "."
}
}
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"],
},
"include": ["**/*.ts"]
}
Hope This helps someone
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
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:
4.0.0+ but 4.1.0 fixed some bugs. They published a changelog.
@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.
browser-sync
latest version.This is bad experience when I'm following the cookbook and facing this error. Please fix either the documentation or the code.
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.
Also encountered. Why not fix it? It's been open since June 2022 and still getting attention
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
This error message is confusing. It's not clear what the implication is. My test seems to run fine.
after adding "baseUrl": "."
in tsconfig from comments warning dissappears. I'm guessing that is the issue
It's a limitation of an old version of tsconfig-paths. It is no longer needed in >4 should cypress finally update.
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.
@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?
I am using nodejs version 16.
@Raihanhn Could you give the name and version of your operating system as well?
Windows 7, 64-bit
@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.
Okay.Thanks for your info.
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.
I'm facing same issue running
cypress/tsconfig.json exists but "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
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.
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
Not sure if this helps anyone, but for me changing:
"moduleResolution": "bundler"
in tsconfig
to:
"moduleResolution": "node"
resolved the issue
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.
Hello , for me the issue get resolved when i launch cypress using sudo command on mac.
sudo npm i -f
<
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 (see the dir/workspace structure here)
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:Adding
"baseUrl": "./",
to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed incypress.config.ts
Desired behavior
No such error printed to the console.
Test code to reproduce
contents of tsconfig.json:
Logs:
Cypress Version
10.1.10
Other
No response