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.

backend-core: Cannot find type definition file for 'web'. ts(2688)

See original GitHub issue

Package + Version

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/clerk-expo
  • @clerk/backend-core
  • @clerk/clerk-sdk-node
  • @clerk/edge
  • other:

Version:

@clerk/clerk-sdk-node: ^3.2.2
@clerk/backend-core: ^1.1.0
@clerk/types: ^2.2.0

Browser/OS

OSX 12.3 Nodejs 16.14.2 Typescript 4.6.3

Description

My backend project refuses to compile correctly.

tsconfig.json:

{
    "compilerOptions": {
        "lib": ["es2020", "dom"],
        "target": "es2020",
        "module": "CommonJS",
        "sourceMap": true,
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "baseUrl": "./src",
        "outDir": "./build",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "esModuleInterop": true,
        "strictNullChecks": true
    },
    "files": ["..."],
    "include": ["src/**/*.ts"]
}

Compilation errors :

node_modules/@clerk/backend-core/dist/cjs/api/resources/Props.d.ts(1,23): error TS2688: Cannot find type definition file for 'web'.
node_modules/@clerk/backend-core/dist/cjs/Base.d.ts(1,23): error TS2688: Cannot find type definition file for 'web'.
node_modules/@clerk/backend-core/dist/cjs/util/types.d.ts(1,23): error TS2688: Cannot find type definition file for 'web'.

It comes from /// <reference types="web" />

What is weird is that I do not have this issue in my nextjs frontend, with the same @clerk/backend-core version (same typescript, nodejs and @clerk/clerk-sdk-node).

But even in my nextjs project: when I open Props.d.ts or Base.d.ts or types.d.ts: it says Cannot find type definition file for 'web'.ts(2688). But it compiles.

I tried several tsconfig changes. Nothing is working.

Any idea ?

Thanks.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
no2chemcommented, Aug 5, 2022

@nomocas Why was this issue closed? It’s definitely a problem with this package, and I’m not sure why @types/web is required for a backend package.

This is a bigger problem now because @types/node now conflicts @types/web over the AbortSignal declaration, necessitating skipLibCheck: true in tsconfig.json to compile:

node_modules/@types/web/index.d.ts:2007:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; timeout(milliseconds: number): AbortSignal; }'.

2007 declare var AbortSignal: {
                 ~~~~~~~~~~~

  node_modules/@types/node/globals.d.ts:72:13
    72 declare var AbortSignal: {
                   ~~~~~~~~~~~
    'AbortSignal' was also declared here.


Found 1 error.

We should keep the issue open so that the maintainers can track/fix it.

1reaction
nomocascommented, Mar 29, 2022

Ok fixed :

I should add @types/web explicitly in my project, and remove “dom” in my tsconfig./lib entry.

tsconfig.json:

{
    "compilerOptions": {
        "lib": ["es2020"],
        "target": "es2020",
        "module": "CommonJS",
        "sourceMap": true,
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "baseUrl": "./src",
        "outDir": "./build",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "esModuleInterop": true,
        "strictNullChecks": true
    },
    "files": ["..."],
    "include": ["src/**/*.ts"]
}

In the clerk mono-repo: @types/web is only added to the root of the mono-repo. Not in backend-core nor in clerk-sdk-node.

I believe that it should be added to avoid same issue next time.

In the frontend (nextjs with @clerk/nextjs project with /api/... stuffs that use clerk-sdk-node), I do not find any @types/web (and yarn why @types/web find it neither). So it’s not clear why it’s compiling in my frontend.

But ok, it compiles in both.

Cheers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error TS2688: Cannot find type definition file for...random paths.
These errors occur when you have subdirectories of a typeRoots directory (in this case node_modules/@types ) that do not contain index.d.ts ...
Read more >
Build:Cannot find type definition file for 'node' - Stack Overflow
The template I started with used an older version of Angular, so I updated the package references. When I build, the first error...
Read more >
Cannot find type definition file for 'node' in TypeScript
To solve the error "Cannot find type definition file for node", install the node types by running npm i -D @types/node . If...
Read more >
Error TS2688: Cannot find type definition file for 'node'
If am receiving this error when running the vtex link command: Webpack for react@3.x builder finished in 464ms with errors: [at-loader] ...
Read more >
Release Notes for the UI5 Type Definitions - SAP
TS2688 Cannot find type definition file for 'node_modules'. This error can be displayed by the TypeScript compiler and at the first character of...
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