0Pricing
Edge Computing with Cloudflare Workers & Deno · 강의

Worker 환경 설정하기

Wrangler CLI를 사용하여 Cloudflare Workers 개발을 위한 로컬 컴퓨터를 구성합니다.

Worker 환경 설정하기은(는) CoddyKit의 무료 Edge Computing with Cloudflare Workers & Deno 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Edge Computing with Cloudflare Workers & Deno 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Edge Computing with Cloudflare Workers & Deno 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Get Ready for Edge Dev

Welcome! Before we build our first Cloudflare Worker, we need to set up our local development environment. This ensures you have all the tools to write, test, and deploy your code efficiently.

A proper setup makes the development process smooth and helps you quickly iterate on your edge applications.

Wrangler: Your Worker Tool

Our primary tool for interacting with Cloudflare Workers is the Wrangler CLI (Command Line Interface). It's a powerful tool that helps you:

  • Create new Worker projects
  • Develop and test Workers locally
  • Configure and deploy Workers to Cloudflare's edge
  • Manage Worker resources

Essential: Node.js & npm

Wrangler is built using Node.js, so you'll need Node.js and its package manager, npm (or yarn), installed on your machine.

  • Node.js: A JavaScript runtime environment.
  • npm: Node Package Manager, used to install libraries and tools.

If you don't have Node.js, download it from nodejs.org. We recommend using a Long Term Support (LTS) version.

Installing Wrangler CLI

Once Node.js and npm are ready, open your terminal or command prompt. We'll install Wrangler globally so it's accessible from any directory.

Run the following command:

npm install -g wrangler

Connect to Cloudflare

After installing, you need to link Wrangler to your Cloudflare account. This allows Wrangler to deploy and manage Workers on your behalf.

Execute this command and follow the browser prompts to log in:

wrangler login

Create Your First Project

Now that Wrangler is installed and authenticated, let's create a new Worker project. This command generates a basic project structure for you.

Replace my-first-worker with your desired project name:

wrangler generate my-first-worker

Understanding Project Structure

After running wrangler generate, you'll find a new directory (e.g., my-first-worker) with essential files:

  • wrangler.toml: Your Worker's configuration file.
  • src/index.js: The main JavaScript file where your Worker's logic lives.
  • package.json: Standard Node.js package file (optional, for dependencies).

Let's dive into these key files.

Configure with wrangler.toml

The wrangler.toml file is crucial. It defines your Worker's settings, like its name, type, and associated Cloudflare account.

Here's a basic example of what it might contain:

name = "my-first-worker"
main = "src/index.js"
compatibility_date = "2023-10-26"
account_id = "YOUR_CLOUDFLARE_ACCOUNT_ID"

Your Worker's Logic

The src/index.js file is where you write the JavaScript code for your Worker. Cloudflare Workers typically listen for fetch events.

This simple Worker responds with "Hello Cloudflare Workers!" to any request:

export default {
  async fetch(request, env, ctx) {
    return new Response("Hello Cloudflare Workers!");
  },
};

Test Your Worker Locally

Before deploying, you can test your Worker right on your machine! Wrangler creates a local development server that simulates the Cloudflare edge environment.

Navigate into your project directory (e.g., cd my-first-worker) and run:

wrangler dev

Wrangler Command Check

Which Wrangler command is used to connect your local environment to your Cloudflare account?

Recap: Setup Complete!

Great job! You've successfully set up your Cloudflare Workers development environment. You've learned how to:

  • Install Wrangler CLI
  • Authenticate with Cloudflare
  • Generate a new Worker project
  • Understand the basic project structure
  • Run your Worker locally using wrangler dev

You're now ready to start building powerful applications at the edge!

자주 묻는 질문

“Worker 환경 설정하기” 강의는 무료인가요?

네 — “Worker 환경 설정하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Edge Computing with Cloudflare Workers & Deno 강의 전체를 잠금 해제할 수 있습니다. Edge Computing with Cloudflare Workers & Deno 강의에는 총 4개의 강의가 포함되어 있습니다.

“Worker 환경 설정하기”에서 뭘 배우나요?

Wrangler CLI를 사용하여 Cloudflare Workers 개발을 위한 로컬 컴퓨터를 구성합니다. 브라우저에서 직접 실행하는 실습 코드로 Edge Computing with Cloudflare Workers & Deno을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Edge Computing with Cloudflare Workers & Deno을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Edge Computing with Cloudflare Workers & Deno은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“Worker 환경 설정하기” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Edge Computing with Cloudflare Workers & Deno 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Edge Computing with Cloudflare Workers & Deno 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Worker 환경 설정하기
  2. HTTP 요청 처리하기
  3. 첫 Worker 배포하기
  4. 워커의 환경 변수 및 비밀값
← Edge Computing with Cloudflare Workers & Deno(으)로 돌아가기