cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

Error: Debug is not a function #23402

Closed kgano-ucsd closed 2 years ago

kgano-ucsd commented 2 years ago

Current behavior

Currently, I am receiving this error when I run npx cypress open or npx cypress run in my project: const debug = Debug('cypress:server:lib:util:suppress_warnings') ^ TypeError: Debug is not a function at Object.<anonymous> (/root/.cache/Cypress/10.3.0/Cypress/resources/app/node_modules/@packages/server/lib/util/suppress_warnings.js:4:15) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Module._extensions..js (node:internal/modules/cjs/loader:1157:10) at Object.require.extensions.<computed> [as .js] (/root/.cache/Cypress/10.3.0/Cypress/resources/app/node_modules/ts-node/src/index.ts:1445:43) 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.<anonymous> (/root/.cache/Cypress/10.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js:3:1) at Module._compile (node:internal/modules/cjs/loader:1103:14) I have tried to run cypress both locally and out of a docker container with this command: docker run -it -v $PWD:/e2e -w /e2e cypress/included:10.3.0 and receive the same issue every time.

For more context, here is the typescript config file we are using: { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "useUnknownInCatchVariables": true, "noFallthroughCasesInSwitch": true, "noImplicitThis": false, "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "react-jsx", "baseUrl": "./src", "module": "es6", "declaration": true, "emitDeclarationOnly": true, }, "include": [ "src", "src/components/**/*", "src/**/*", "src/custom.d.ts", "jest/jest-setup.js", ], } And the tsconfig for cypress itself.... { "compilerOptions": { "target": "es5", "lib": ["es5", "dom"], "types": ["cypress", "cypress-file-upload", "node"] }, "include": ["**/*.ts", "../src/components/pages/PredictUpload/predict-upload.cy.ts"] }

Desired behavior

Ideally, cypress should just launch as expected. I have tried my coworker's computer (mac) and it works fine on his machine, and we also run cypress as a github action and it works fine there as well. For further context, I am running Windows 11, in case that has anything to do with it.

Test code to reproduce

Simply 'npx cypress run' or 'npx cypress open'. Even commands like 'npx cypress imply that cypress is verified.

Cypress Version

10.3.0

Node version

v16.15.1

Operating System

Windows 11

Debug Logs

No response

Other

No response

rachelruderman commented 2 years ago

Hi @kgano-ucsd ! I found a similar issue reported on pullanswer.com. Can we try the following:

  1. Remove tsconfig.json in your project and run npx cypress run. Does it work?
  2. Restore tsconfig.json, set "baseUrl": "./src" and run npx cypress run. What happens then?

Thanks

nagash77 commented 2 years ago

Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.

morulus commented 1 year ago

I had such a problem. And I solved it as soon as I looked at the place of the error. It requires "debug" package! If you have any file in the root which matches "debug.{ts|js|json}" cypress will import this file instead of "debug" package from node_modules.

The cure: remove file debug.{ts|js|json} from the root of your project. Cheers!