question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type Error chalk.instance is not a constructor

See original GitHub issue

Current behavior

Updating to 6.3.0 running any .ts files I am getting an error

Webpack failed to compile, TypeError: chalk.Instance is not a constructor

The dependency causing this is ts-loader 8.0.14 found in the Cypress Cache: Cypress/6.3.0/Cypress/resources/app/packages/server/node_modules/ts-loader

Desired behavior

Tests should run normally

Test code to reproduce

In a testfile.ts:

it("Wants to Test", () => {
    cy.visit("https://google.com");
})

Try to run the file you get:

image

These are my current package.json dependencies:

"dependencies": {
    "@types/node": "^14.14.22",
    "@typescript-eslint/eslint-plugin": "^4.14.0",
    "@typescript-eslint/parser": "^4.14.0",
    "cypress": "^6.3.0",
    "eslint": "^7.18.0",
    "mocha": "^8.1.3",
    "mochawesome": "^6.1.1",
    "mochawesome-merge": "^4.2.0",
    "mochawesome-report-generator": "^5.1.0",
    "typescript": "^4.1.3"
  }

Npm Version 6.13.1 Node version 12.16.1

Also tried in a different VM (same dependencies though): Npm Version 6.14.10 Node version 14.15.4

Versions

6.3.0

Workaround

Take the ts-loader from the cached Cypress 6.2.1 and copy paste it (cause this one is 8.0.13) works fine for me, but not sure what kind of side effects this might cause

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
cbrugecommented, Jan 25, 2021

Hey @jennifer-shehane after more extensive research (including trying to recreate it with a fresh repo) I found the solution. I deleted the node_modules and package-lock.json. Installed everything fresh and it worked. I could have sworn I tried that before…oh well. 6.3.0 is running smooth now👌🏼

0reactions
eppsiloncommented, Oct 29, 2021

Modifying tsconfig.json fixed this issue for me: https://github.com/cypress-io/cypress/issues/17802#issuecomment-955071058

Read more comments on GitHub >

github_iconTop Results From Across the Web

chalk.default.constructor is not a constructor in next.js
After adding getServerSideProps in Index.jsx error start to appear. TypeError: _chalk.default.constructor is not a constructor at Object.
Read more >
TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >
TypeError: Chalk is not a constructor #513 - Issuehunt
Issue. I tried to instantiate a chalk instance so I could alter the level based on this example in the docs and received...
Read more >
Resolving TypeError: "X" is Not a Constructor in JavaScript
JavaScript "TypeError: "x" is not a constructor" errors occur when invalid objects or a variable is erroneously used as a constructor.
Read more >
Hi, to fix this `o.default is not a constructor`, you need to adjust ...
to:. “Hi, to fix this `o.default is not a constructor`, you need to adjust your import statement, from:” is published by Éverton Roberto...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found