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

TypeError: tsInvariant.setVerbosity is not a function #9094

Open
sashberd opened this issue Nov 22, 2021 · 9 comments
Open

TypeError: tsInvariant.setVerbosity is not a function #9094

sashberd opened this issue Nov 22, 2021 · 9 comments

Comments

@sashberd
Copy link

sashberd commented Nov 22, 2021

Just updated from 3.2.5 to latest version to apollo and on local run I get this error:

TypeError: tsInvariant.setVerbosity is not a function
    at Object../node_modules/@apollo/client/core/core.cjs 

I tried to add tsInvariant as dev dependency, but still no luck. Anyway, why I need any ts lib if I use simple React?

 "@apollo/client": "^3.5.4",
  "react": "^16.8.4",
@benjamn
Copy link
Member

benjamn commented Nov 22, 2021

@sashberd Do you see anything installed in node_modules/ts-invariant/? If so, what version do you see in ts-invariant/package.json? Are there multiple copies of ts-invariant installed (try running npm ls ts-invariant)?

@sashberd
Copy link
Author

@benjamn FYR

Screen Shot 2021-11-23 at 9 53 09

There is only 1 version 0.4.4

@saarhaber
Copy link

saarhaber commented Nov 24, 2021

Hi, I am facing a similar issue.

I updated to version 3.5.5 (to fix the ts-invariant/process issue that was solved in 3.5.4).

What I see when I run it:
image

In ts-invariant/package.json I have version 0.9.3
When I run npm ls ts-invariant I see:
image

@benjamn Any idea how to solve it? Thanks.

@benjamn
Copy link
Member

benjamn commented Dec 6, 2021

@saarhaber Does node_modules/@apollo/client/node_modules/ts-invariant/package.json exist? It should have "version": 0.9.3 (the latest version), and the @apollo/client package should be importing from that version of ts-invariant and not any other version.

Ideally there would only be one copy of ts-invariant installed, but multiple copies are legal and should operate independently. You might also try removing graphql-anywhere unless you're actually using it, though I don't expect that to fully/immediately solve this problem.

@saarhaber
Copy link

With Yarn resolutions and version 0.9.3 the issue is gone. Thanks!

@sashberd
Copy link
Author

@benjamn I still have this issue after update to latest version
Here the SS for command you asked me before:
Screen Shot 2021-12-29 at 15 37 12
Any updates how to workaround this one?

@evan-sheehan
Copy link

evan-sheehan commented Jan 11, 2022

I'm having the same issue for what it's worth, but I seemingly only have one version of ts-invariant installed:
image

In addition:
I'm not sure if Ts Invariant is exporting incorrectly or if Apollo client is importing incorrectly, OR if SvelteKit/Vite is packaging everything in a way that screws everything up. In this second screenshot you can see that the tsInvariant var in apollo/client/core/core.cjs is importing the default export from the ts-invariant package which doesn't seem to contain the setVerbosity function:
Screenshot from 2022-01-11 08-21-05

Hopefully I'm missing something obvious. I'm guessing this is some Vite compatibility issue, but I'm not sure how to handle it.

@evan-sheehan
Copy link

evan-sheehan commented Jan 11, 2022

Fixed my issue per this StackOverflow post: https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found

In my SvelteKit/Vite project I added this to the svelte.config for the vite config settings:
image

I also needed to properly import Apollo client functions via "@apollo/client/core/index.js". Don't think this will help OP, but might be useful for someone else.

@kachkaev
Copy link

kachkaev commented Jul 6, 2022

I also experienced this issue because of ts-invariant@0.4.4 from apollo-server-express. @apollo/client has ts-invariant@0.10.3.

yarn why ts-invariant

=> Found "ts-invariant@0.4.4"
info Has been hoisted to "ts-invariant"
info Reasons this module exists
   - "workspace-aggregator-c9429ed8-aa29-4009-91b3-05901eee841c" depends on it
   - Hoisted from "_project_#@hashintel#hash-api#apollo-server-express#graphql-tools#apollo-link#ts-invariant"
   - Hoisted from "_project_#@hashintel#hash-api#apollo-server-express#graphql-tools#apollo-utilities#ts-invariant"
info Disk size without dependencies: "144KB"
info Disk size with unique dependencies: "224KB"
info Disk size with transitive dependencies: "224KB"
info Number of shared dependencies: 1
=> Found "@apollo/client#ts-invariant@0.10.3"
info This module exists because "_project_#@hashintel#hash-api#@apollo#client" depends on it.
info Disk size without dependencies: "80KB"
info Disk size with unique dependencies: "160KB"
info Disk size with transitive dependencies: "160KB"
info Number of shared dependencies: 1
✨  Done in 0.44s.

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

No branches or pull requests

6 participants