grammyjs / grammY

The Telegram Bot Framework.
https://grammy.dev
MIT License
2.39k stars 118 forks source link

Can't deploy conversations plugin on Cloudflare Workers #564

Closed Nesquik closed 6 months ago

Nesquik commented 6 months ago

Hi there, I'm getting the following error while trying to build a bot on Cloudflare after having installed the conversations plugin:

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/chmod.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/chown.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/copyFile.js:31:32:
      31 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/link.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/lstat.js:31:32:
      31 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/makeTempDir.js:5:27:
      5 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/mkdir.js:8:27:
      8 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/readDir.js:8:27:
      8 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/readFile.js:8:27:
      8 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/readLink.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/readTextFile.js:8:27:
      8 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/realPath.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/remove.js:5:27:
      5 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/rename.js:5:27:
      5 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/stat.js:8:27:
      8 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/symlink.js:28:32:
      28 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/truncate.js:31:32:
      31 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/watchFs.js:5:27:
      5 │ const promises_1 = require("fs/promises");
        ╵                            ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/writeFile.js:31:32:
      31 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs/promises"

    node_modules/@deno/shim-deno/dist/deno/stable/functions/writeTextFile.js:31:32:
      31 │ const fs = __importStar(require("fs/promises"));
         ╵                                 ~~~~~~~~~~~~~

  The package "fs/promises" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Build failed with 20 errors:

  node_modules/@deno/shim-deno/dist/deno/stable/functions/chmod.js:28:32: ERROR: Could not
  resolve "fs/promises"
  node_modules/@deno/shim-deno/dist/deno/stable/functions/chown.js:28:32: ERROR: Could not
  resolve "fs/promises"
  node_modules/@deno/shim-deno/dist/deno/stable/functions/copyFile.js:31:32: ERROR: Could not
  resolve "fs/promises"
  node_modules/@deno/shim-deno/dist/deno/stable/functions/link.js:28:32: ERROR: Could not
  resolve "fs/promises"
  node_modules/@deno/shim-deno/dist/deno/stable/functions/lstat.js:31:32: ERROR: Could not
  resolve "fs/promises"
  ...

My package.json dependencies:

  "dependencies": {
    "@grammyjs/conversations": "^1.2.0",
    "@grammyjs/menu": "^1.2.1",
    "@grammyjs/storage-cloudflare": "^2.4.2",
    "dotenv": "^16.4.5",
    "drizzle-orm": "^0.30.10",
    "grammy": "^1.22.4",
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20240423.0",
    "@types/node": "^20.12.8",
    "drizzle-kit": "^0.20.17",
    "typescript": "^5.4.5",
    "wrangler": "3.53.0"
  }

From the looks of it o-son has @deno/shim-deno as a dependency and it all breaks down from there.

My wrangler.toml already has the node_compat = true and compatibility_date = "2023-01-16" like noted here: https://grammy.dev/hosting/cloudflare-workers-nodejs

Any hints on how to approach this would be very appreciated, thanks.

Nesquik commented 6 months ago

Sorry, reopened here: https://github.com/grammyjs/conversations/issues/104