'How can I fix cypress error on github pages?

I'm getting this error when I run the tests on github pages, the app uses rails as backend and svelte for front end.

TypeError: chalk.Instance is not a constructor
    at new TsconfigPathsPlugin (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/node_modules/tsconfig-paths-webpack-plugin/lib/plugin.js:17:47)
    at addTypeScriptConfig (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/node_modules/@cypress/webpack-batteries-included-preprocessor/index.js:54:37)
    at Object.handler (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/node_modules/@cypress/webpack-batteries-included-preprocessor/index.js:166:7)
    at invoke (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:22:16)
    at /home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/util.js:45:14
    at tryCatcher (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Object.wrapChildPromise (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/util.js:44:23)
    at Object.wrap (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/child/preprocessor.js:28:8)
    at execute (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:119:27)
    at EventEmitter.<anonymous> (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:209:5)
    at EventEmitter.emit (events.js:210:5)
    at process.<anonymous> (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/packages/server/lib/plugins/util.js:19:22)
    at process.emit (events.js:210:5)
    at process.emit (/home/runner/.cache/Cypress/9.4.1/Cypress/resources/app/node_modules/source-map-support/source-map-support.js:495:21)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

I have upgraded cypress and I still get this error I can't find references to similar error. Also have reinstalled everything fresh and did not solve the issue. Also checked my tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "module": "es6",
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "*": ["node_modules/*", "app/javascript/*", "app/webpacker/*"],
      "@/*": ["app/webpacker/packs/*"]
    },
    "sourceMap": true,
    "target": "es6",
    "noEmit": true,
    "types": ["cypress", "cypress-file-upload"]
  },
  "exclude": ["**/*.spec.ts", "node_modules", "vendor", "public"],
  "compileOnSave": false
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source