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

"Couldn't find tsconfig.json" error in JavaScript monorepo #30907

Open
MikeMcC399 opened this issue Jan 17, 2025 · 2 comments
Open

"Couldn't find tsconfig.json" error in JavaScript monorepo #30907

MikeMcC399 opened this issue Jan 17, 2025 · 2 comments
Labels

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jan 17, 2025

Current behavior

Running Cypress in a pure JavaScript monorepo project, where TypeScript is a transient dependency in the root of the monorepo, results in the warning:

"Couldn't find tsconfig.json. tsconfig-paths will be skipped."

if the dependencies for the root project are also installed.

Desired behavior

In a pure JavaScript monorepo (sub-)project with its own package.json containing no TypeScript references, the following warning should not be output. This should be independent of any TypeScript configured in the root of the repo.

"Couldn't find tsconfig.json. tsconfig-paths will be skipped."

tsconfig.json should not be required if a project is pure JavaScript.

Test code to reproduce

git clone https://github.com/cypress-io/github-action
cd github-action
git clean -xfd # if repeating tests
npm ci
cd examples/basic
npm ci
npm test

shows warning

"Couldn't find tsconfig.json. tsconfig-paths will be skipped."

then

rm -rf ../../node_modules
npm test

and confirm no warning regarding missing tsconfig.json.

Cypress Version

14.0.0
This is not a regression in 14.0.0. It is also reproducible in 13.17.0.

Node version

v22.13.0 LTS

Operating System

Ubuntu 24.04.1 LTS

Debug Logs

$ npm test

> [email protected] test
> cypress run


DevTools listening on ws://127.0.0.1:46049/devtools/browser/59c53df9-eae8-45e3-b33e-26a42e8939d7
Couldn't find tsconfig.json. tsconfig-paths will be skipped

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        14.0.0                                                                         │
  │ Browser:        Electron 130 (headless)                                                        │
  │ Node Version:   v22.13.0 (/home/mike/n/bin/node)                                               │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

with root dependencies installed:

  cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/basic', '--file', '/home/mike/github/cypress-io/github-action/examples/basic/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/basic', execPath: '/home/mike/n/bin/node' } } +0ms
  cypress:lifecycle:ProjectConfigIpc found typescript in /home/mike/github/cypress-io/github-action/examples/basic +6ms
  cypress:lifecycle:ProjectConfigIpc using cjs with --require /home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/register_ts_node.js +0ms
  cypress:lifecycle:ProjectConfigIpc trigger the load of the file +25ms
Couldn't find tsconfig.json. tsconfig-paths will be skipped
  cypress:lifecycle:ProjectConfigIpc loadConfig:reply +811ms

when root dependencies not installed:

    cypress:lifecycle:ProjectConfigIpc fork child process { CHILD_PROCESS_FILE_PATH: '/home/mike/.cache/Cypress/14.0.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', configProcessArgs: [ '--projectRoot', '/home/mike/github/cypress-io/github-action/examples/basic', '--file', '/home/mike/github/cypress-io/github-action/examples/basic/cypress.config.js' ], childOptions: { stdio: 'pipe', cwd: '/home/mike/github/cypress-io/github-action/examples/basic', execPath: '/home/mike/n/bin/node' } } +0ms
  cypress:lifecycle:ProjectConfigIpc no typescript found, just use regular Node.js +2ms
  cypress:lifecycle:ProjectConfigIpc trigger the load of the file +13ms
  cypress:lifecycle:ProjectConfigIpc loadConfig:reply +442ms

Other

This issue became apparent in https://github.com/cypress-io/github-action after the forced migration to @actions/[email protected] from @actions/[email protected]

Whereas @actions/[email protected] contains no typescript transient dependency, @actions/[email protected] pulls in @protobuf-ts/plugin@^2.9.4 and thereby typescript@^3.9:

$ npm ls typescript
└─┬ @actions/[email protected]
  └─┬ @protobuf-ts/[email protected]
    ├─┬ @protobuf-ts/[email protected]
    │ └── [email protected] deduped
    └── [email protected]

The issue does not show up in the GitHub Action examples running in workflows because then only the dependencies of the tested project, such as examples/basic, are installed, without the unneeded dependencies of the root of the repo.

However, when working locally, if npm ci has been run in the root of the repo clone, and then npm ci is run in an example project, Cypress looks up the hierarchy and finds typescript in the root. It then assumes that the whole repo is TypeScript, which is incorrect.

@jennifer-shehane
Copy link
Member

@MikeMcC399 Similar to this issue, although that issue only mentions TS projects as a problem. #22273

@jennifer-shehane jennifer-shehane added type: error message Reproducible Can be reproduced stage: ready for work The issue is reproducible and in scope and removed stage: ready for work The issue is reproducible and in scope labels Jan 17, 2025
@MikeMcC399
Copy link
Contributor Author

@jennifer-shehane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants