Skip to content

Can't find module "cloudflare:workers" when using target: 'cloudflare-module' #4687

@astralarya

Description

@astralarya

Which project does this relate to?

Start

Describe the bug

Create a project with target: 'cloudflare-module' and add a CloudFlare durable object class.

I have created a minimal repo based on the start-basic template.

Your Example Website or App

https://github.com/astralarya/tanstack-start-cloudflare-durable-objects

Steps to Reproduce the Bug or Issue

Clone the repo linked above and run:

npm install
npm run dev

Then visit the locally hosted webpage (probably at port 3000).

Expected behavior

Wrangler should be able to simulate Durable Objects locally during development. Instead, visiting the local webpage gives the following error:

Error: Cannot find module 'cloudflare:workers' imported from '/path/to/repo/tanstack-start-cloudflare-durable-objects/src/utils/durable.ts'

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.128.1
  • OS: MacOS
  • Browser: Chrome
  • Browser Version: 138.0.7204.49
  • Bundler: vite
  • Bundler Version: v6.3.5

Additional context

The module "cloudflare:workers" is not a regular npm package, but something provided by the Cloudflare runtime in production and Wrangler during development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions