Install and Configure the Cloudflare Workers CLI Wrangler

Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

Using NPM, you can install Cloudflare Workers' CLI (command-line interface), Wrangler, by typing npm install -g @cloudflare/wrangler into your command line. Wrangler allows you to generate and publish Cloudflare Workers projects. We'll also use the wrangler login command which will give you a link to authorize Wrangler. This will set up an API token specifically for your Wrangler installation that will allow you to publish and read all the Workers and Workers KV information that you need.

Instructor: [0:01] With my Cloudflare Workers account created, it's time to install Wrangler, the command line tool that we use to create and publish Workers projects. I'm in Visual Studio Code shell, but you can use pretty much any shell that you would like, and the only requirement is that you have npm installed.

[0:15] You can see I have npm 7. installed, and I'm using Node version 15.3. With npm installed, all I need to do is run npm install -g with the package name cloudflare/wrangler. It'll grab all the packages that I need. You can see if I run wrangler --version, it prints out Wrangler 1.12.2.

[0:40] With Wrangler installed, it's now time to authenticate my Wrangler installation with my Cloudflare workers user. To do that, I'll just run wrangler login. It'll ask if I want to open a page in my browser. I'll say Y for Yes.

[0:54] Depending on your operating system, your shell, sometimes this will open up the link. Though, in my case, it didn't, because I'm on the Windows subshell. I'll just copy this. Go back to my Workers tab. I'll paste this link in.

[1:08] You can see it will basically set up an API token specifically for my Wrangler installation that will allow me to publish and read all the Workers and Workers KV information that I need, so I'll just click Authorize wrangler. It's now authorized. If I come back to my terminal, you can see it says, "Successfully configured. You can find your configuration file at," and then there's this path here.

[1:33] The last thing that I want to do is make sure that I'm logged in with what I would expect, so I'll run wrangler whoami. You can see that it prints out, "You are logged in with an API token associated with the email," and then this is my email here, as well as my account name and my account ID, which we'll use later on to publish our first Workers project.

egghead
egghead
~ 11 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today