Skip to content

TypeScript Error: Cannot find module 'node:stream' or its corresponding type declarations. #2921

@ZebraNorth

Description

@ZebraNorth

@inertiajs/vue3 Version

2.3.17

Backend stack (optional)

No response

Describe the problem

Checking my project's TypeScript syntax with vue-tsc --noEmit gives the following error:

node_modules/@vue/server-renderer/dist/server-renderer.d.ts:2:36 - error TS2307: Cannot find module 'node:stream' or its corresponding type declarations.

2 import { Writable, Readable } from 'node:stream';

This is due to PR #2648 adding import { renderToString } from 'vue/server-renderer' to vue3/src/createInertiaApp.ts.

Importing vue/server-renderer in turn tries to import node:stream, which fails because it is not in a NodeJS environment, it is in a web browser environment.

Adding @types/node to the project is not a viable solution because it conflicts with client side definitions (for example setTimeout(): number vs setTimeout(): Timeout).

Steps to reproduce

Create a file app.ts containing:

import { createInertiaApp } from '@inertiajs/vue3';

Run:

npx vue-tsc --noEmit

Metadata

Metadata

Assignees

No one assigned

    Labels

    vue 3Related to the vue 3 adapter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions