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
10 Replies
oh interesting.. on 3.74.0 but when I update:
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.
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: how do we do it?
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 🤔hopefully Skye will find time to help us out
OKay it's working ,I had a typo in the code
It's cloudflare:workers not @Cloudflare:workers
exact same issue for me:
wondering the same
same.. using
@hono-rate-limiter/cloudflare
setting in vite doesn't help either: