ERROR Could not resolve "cloudflare:workers"

Refactoring our working WebSockets to use Durable Objects with RPC methods. Using the Durable Object sample to start with no errors or warnings. But on build: ✘ [ERROR] Could not resolve "cloudflare:workers" src/durable-objects/testws.do.ts:3:30: 3 │ import { DurableObject } from 'cloudflare:workers' [@Cloudflare/workers-types 4.2 node v20.17.0 npm 10.8.2 ] Not sure if this is a package problem or config issue or what.. TIA for any direction
No description
No description
10 Replies
Brod
BrodOP3mo ago
oh interesting.. on 3.74.0 but when I update:
No description
Brod
BrodOP3mo ago
No idea how that devDependency got messed up. Fixed that. updated to ⛅️ wrangler 3.75.0 same: ✘ [ERROR] Could not resolve "cloudflare:workers" That was it! Mad at myself for not trusting the error handling message. Had to play with DO migrations a bit, but now have a new DO to build out our new WS connection. Very exciting. Thank you Skye - this was a major roadblock. Should have asked sooner.
zsmooth
zsmooth2mo ago
How do we satisfy eslint with this import? Is there a cloudflare template that has eslint set up that demonstrates? eslint doesn't know how to resolve cloudflare:workers, so it complains about import { DurableObject } from "cloudflare:workers";. I just shut it off though and things seem to work fine:
// eslint-disable-next-line import/no-unresolved
import { DurableObject } from "cloudflare:workers";
// eslint-disable-next-line import/no-unresolved
import { DurableObject } from "cloudflare:workers";
bkyerv
bkyerv3w ago
how do we do it?
Aster
Aster3w ago
Hey 👋 Same issue here, with "@cloudflare/workers-types to 4.20241022.0 (and set to same date in tsconfig: compilerOptions.types -> @cloudflare/workers-types/2024-10-22) + wrangler latest version, I get Cannot find module '@cloudflare:workers' or its corresponding type declarations. in my editor 🤔
Aster
Aster3w ago
No description
bkyerv
bkyerv3w ago
hopefully Skye will find time to help us out
Aster
Aster3w ago
OKay it's working ,I had a typo in the code It's cloudflare:workers not @Cloudflare:workers
mr nooli
mr nooli3w ago
exact same issue for me:
src/durable-object.ts:2:30:
2 │ import { DurableObject } from "cloudflare:workers";
src/durable-object.ts:2:30:
2 │ import { DurableObject } from "cloudflare:workers";
wondering the same
predaytor
predaytor2w ago
same.. using @hono-rate-limiter/cloudflare setting in vite doesn't help either:
ssr: {
resolve: {
conditions: ['workerd', 'worker', 'browser'],
},
external: ['cloudflare:workers'],
},
ssr: {
resolve: {
conditions: ['workerd', 'worker', 'browser'],
},
external: ['cloudflare:workers'],
},
Want results from more Discord servers?
Add your server