Migration script fails

So When I try to run an auto generated migration script using the cli, it fails giving me this error:

Error: Must use import to load ES Module: /Users/omni/repos/treyd/migrations/1680084615_addQuoteWithImageBlock.ts
    require() of ES modules is not supported.
    require() of /Users/omni/repos/treyd/migrations/1680084615_addQuoteWithImageBlock.ts from 
    /Users/omni/repos/treyd/node_modules/@datocms/cli/lib/commands/migrations/run.js is an ES module file as it is a .ts file whose 
    nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
    Instead change the requiring code to use import(), or remove "type": "module" from /Users/omni/repos/treyd/package.json.

This is a sveltekit project that has a type=module in package.json

Hey @mohamed.elshazly and welcome to the community!

Have you taken a look at this thread?

As i think it may solve your issue!
Let me know,

I did in my search actually yea, but my problem with it is that I canโ€™t find the file named command.js. Iโ€™m not using datocms-client (I believe that is the old cli? ). Iโ€™m using, however, @datocms/cli

I managed to do a work around:

  1. Remove type=module
  2. make sure the migrations is a js file
  3. run them
  4. put the type back in

I however encountered this error:

Error: POST https://site-api.datocms.com/items: 404 Not Found
        "id": "302048",
        "type": "api_error",
        "attributes": {
          "code": "NOT_FOUND",
          "details": {}

The migrations run correctly but the running of the script always fails with this error at the very end

Hello @mohamed.elshazly

Can you email us at support@datocms.com with your migration script and the project URL that you are trying to apply it on? That error usually indicates trying to modify a model that does not exist, but we can take a closer look at it