Skip to content

Cannot find module '@opentelemetry/api' or its corresponding type declarations. #14774

@james-pre

Description

@james-pre

Describe the bug

When upgrading to the latest SvelteKit version, attempting to run TSC results in a problem with SvelteKit missing a dependency.

Reproduction

StackBlitz

Logs

$ npx tsc
node_modules/@sveltejs/kit/types/index.d.ts:8:28 - error TS2307: Cannot find module '@opentelemetry/api' or its corresponding type declarations.

8  import type { Span } from '@opentelemetry/api';

System Info

$ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
Need to install the following packages:
[email protected]
Ok to proceed? (y) n

npm error canceled
npm error A complete log of this run can be found in: REDACTED.log

Severity

blocking all usage of SvelteKit

Additional Information

Versions:

  • @sveltejs/kit v2.47.2
  • svelte v5.40.2
  • Node.js v24.9.0

It appears to be from this source: packages/kit/src/exports/public.d.ts:28 (blame)

I think the best way to go about fixing this would be to make sure tsc still works even when the package isn't installed by using // @ts-ignore. This isn't ideal, but realistically it doesn't make sense to add on yet another dependency just for something many users won't even use.

The fix is pretty easy, literally a one-line change:

+// @ts-ignore - some users might not have this installed.
 import { Span } from '@opentelemetry/api';

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions