Err: No event handlers were registered. This script does nothing. When trying to add a DO

Hello! CF newbie here. I have a Workers project that is working successfully. I'm trying to add a durable object but when I try to publish the project with the new DO I get the following error: No event handlers were registered. This script does nothing. [code: 10021]

The error is response to the following command: npm run deploy --new-class ./src/ChessGame.mjs



My wrangler.toml file is as follows:

name = "my-workers-file"
main = "src/worker.mjs"
compatibility_date = "2023-06-09"

[durable_objects]
bindings = [
  { name = "CHESS_GAME_NAMESPACE", class_name = "ChessGame", script_name = "my-workers-file" }
]
[[migrations]]
tag = "v1" 
new_classes = ["ChessGame"]


The directory structure is as follows:
src
  -worker.mjs
  -ChessGame.mjs


My worker.mjs file:

export default {
    async fetch(request, env, context) {
        try {
          //Code 
        } catch (err) {
            //code
        }
    },
};


My ChessGame.js file:

`export class ChessGame {
   constructor(state, env) {
     //initialization code
  }
  async fetch(request) {
   //code
   }
};


My package.json file is as follows:
{
  "scripts": {
    "deploy": "wrangler deploy",
    "start": "wrangler dev"
  },
  "devDependencies": {
    "wrangler": "^3.0.0"
  },
}
`
Interestingly enough, this is the first issue listed under the Common errors section on the CF dev docs(https://developers.cloudflare.com/workers/learning/using-durable-objects/#error-no-event-handlers-were-registered-this-script-does-nothing) but despite following the advice I'm still getting the same error.
Any help would be greatly appreciated! Thank you for building a great product (:
Durable Objects provide low-latency coordination and consistent permanent storage for the Workers platform through two features: global uniqueness and
Was this page helpful?