[GH-ISSUE #648] 请问该如何编译出 worker.js 文件 #246

Closed
opened 2026-02-26 20:36:19 +03:00 by kerem · 2 comments
Owner

Originally created by @Zyx-A on GitHub (Apr 30, 2025).
Original GitHub issue: https://github.com/dreamhunter2333/cloudflare_temp_email/issues/648

请问该如何重新编译出 worker.js 文件,我才接触 TS、nodejs 项目,不是特别清楚如何从 ts 文件编译成 js 文件。
我按网上的教程,尝试了多种方法,都编译不出来,使用如下方法编译出 worker.js 文件,并上传到 cloudflare 平台,则发现运行不起来。

cd cloudflare_temp_email/worker
pnpm install
esbuild src/worker.ts --minify --bundle --outfile=worker.js --platform=node --external:cloudflare:email --external:cloudflare:sockets
Originally created by @Zyx-A on GitHub (Apr 30, 2025). Original GitHub issue: https://github.com/dreamhunter2333/cloudflare_temp_email/issues/648 请问该如何重新编译出 worker.js 文件,我才接触 TS、nodejs 项目,不是特别清楚如何从 ts 文件编译成 js 文件。 我按网上的教程,尝试了多种方法,都编译不出来,使用如下方法编译出 worker.js 文件,并上传到 cloudflare 平台,则发现运行不起来。 ```shell cd cloudflare_temp_email/worker pnpm install esbuild src/worker.ts --minify --bundle --outfile=worker.js --platform=node --external:cloudflare:email --external:cloudflare:sockets ```
kerem closed this issue 2026-02-26 20:36:19 +03:00
Author
Owner

@dreamhunter2333 commented on GitHub (Apr 30, 2025):

运行 pnpm build 即可

<!-- gh-comment-id:2842140877 --> @dreamhunter2333 commented on GitHub (Apr 30, 2025): 运行 pnpm build 即可
Author
Owner

@Zyx-A commented on GitHub (May 6, 2025):

编译步骤:

  1. pnpm install -r 安装所有的依赖
  2. pnpm wrangler deploy src/worker.ts 执行后,登录到cf平台,方便后续调用cf接口
  3. pnpm build 此时编译才不会报错
<!-- gh-comment-id:2853971900 --> @Zyx-A commented on GitHub (May 6, 2025): 编译步骤: 1. `pnpm install -r` 安装所有的依赖 2. `pnpm wrangler deploy src/worker.ts` 执行后,登录到cf平台,方便后续调用cf接口 3. `pnpm build` 此时编译才不会报错
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cloudflare_temp_email#246
No description provided.