brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
690 stars 31 forks source link

Could not resolve "path" when building for Cloudflare Workers #113

Closed sergeysova closed 4 months ago

sergeysova commented 5 months ago

Using:

pnpm vite build
pnpm wrangler build
 ⛅️ wrangler 3.62.0
-------------------

✘ [ERROR] Could not resolve "path"

    node_modules/.pnpm/telefunc@0.1.74_@babel+core@7.23.9_@babel+parser@7.24.5_@babel+types@7.24.5_react-streaming@0_3t7m6eqtjjvdb6ys45f7c5hbhi/node_modules/telefunc/dist/cjs/node/server/runTelefunc/loadTelefuncFilesFromConfig.js:8:23:
      8 │ const path_1 = require("path");
        ╵                        ~~~~~~

  The package "path" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.

✘ [ERROR] Could not resolve "path"

    node_modules/.pnpm/telefunc@0.1.74_@babel+core@7.23.9_@babel+parser@7.24.5_@babel+types@7.24.5_react-streaming@0_3t7m6eqtjjvdb6ys45f7c5hbhi/node_modules/telefunc/dist/cjs/node/server/serverConfig.js:4:23:
      4 │ const path_1 = require("path");
        ╵                        ~~~~~~

  The package "path" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.

✘ [ERROR] Could not resolve "path"

    node_modules/.pnpm/telefunc@0.1.74_@babel+core@7.23.9_@babel+parser@7.24.5_@babel+types@7.24.5_react-streaming@0_3t7m6eqtjjvdb6ys45f7c5hbhi/node_modules/telefunc/dist/cjs/utils/getOutDirs.js:9:39:
      9 │ const path_1 = __importDefault(require("path"));
        ╵                                        ~~~~~~

  The package "path" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.

I use:

vike 0.4.177
vite 5.2.11

Possible solution is to replace all node imports to prefixed. When I actually replaced in node_modules it works correctly