CINXE.COM

Get started with Netlify CLI | Netlify Docs

<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Get started with Netlify CLI | Netlify Docs</title> <meta name="generator" content="VuePress 1.9.10"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,400italic|Roboto+Mono:400"> <link rel="icon" href="/netlify-icon.svg" type="image/svg+xml"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32"> <link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16"> <script>(function (w) { if (!w) return; const darkQuery = w.matchMedia('(prefers-color-scheme: dark)'); const root = document.documentElement; function setTheme(newTheme) { if (newTheme === 'dark' || (newTheme === 'system' && darkQuery.matches)) { root.classList.add('dark-mode'); } else { root.classList.remove('dark-mode'); } w.__theme = newTheme; } w.__setPreferredTheme = function (newTheme) { setTheme(newTheme); try { localStorage.setItem('nf-docs-theme', w.__theme); } catch (err) {} }; // If using system theme, change colors in real time // in response to user settings darkQuery.addEventListener('change', function (event) { if (w.__theme === 'system') { if (event.matches) { root.classList.add('dark-mode'); } else { root.classList.remove('dark-mode'); } } }); let preferredTheme; // Try to get saved theme try { preferredTheme = localStorage.getItem('nf-docs-theme') || 'system'; } catch (err) {} // Initialize preferredTheme setTheme(preferredTheme); })(window);</script> <script src="/rum.js" data-application-id="ededf59a-7705-4933-b2a0-5efa8b35b293" data-client-token="pub1b84fc7c7429f37e025e8160c02da8bb" data-service="docs" data-env="production" defer="true"></script> <meta name="description" content="Install our CLI (command line interface) and use it to run a local development environment, deploy your site, manage environment variables, and more."> <meta property="og:title" content="Get started with Netlify CLI"> <meta property="og:url" content="https://docs.netlify.com/cli/get-started/"> <meta property="og:description" content="Install our CLI (command line interface) and use it to run a local development environment, deploy your site, manage environment variables, and more."> <meta property="og:image" content="https://docs.netlify.com/og-image.png"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta prefix="og: http://ogp.me/ns#" property="og:type" content="article"> <meta prefix="og: http://ogp.me/ns#" property="og:article:author" content="Netlify"> <meta name="google-site-verification" content="G4JqDTXMHpDyWoqIRwgw8PBqg-AncXqtdkHehcOR7kc"> <meta name="slack-app-id" content="A05P27DR8C8"> <link href="https://docs.netlify.com/cli/get-started/" rel="canonical" /> <link rel="preload" href="/assets/css/0.styles.2d136594.css" as="style"><link rel="preload" href="/assets/js/app.4a12bea4.js" as="script"><link rel="preload" href="/assets/js/6.f7eff80e.js" as="script"><link rel="preload" href="/assets/js/2.1c921067.js" as="script"><link rel="preload" href="/assets/js/91.272c9eb8.js" as="script"><link rel="preload" href="/assets/js/16.bc1aa620.js" as="script"><link rel="preload" href="/assets/js/32.07d46218.js" as="script"><link rel="preload" href="/assets/js/31.2c355c7b.js" as="script"> <link rel="stylesheet" href="/assets/css/0.styles.2d136594.css"> </head> <body> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NMKKF2M" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar-header"><div class="navbar"><div class="navbar__logo-link"><a href="/" class="router-link-active"><span class="visuallyhidden">Netlify Docs</span> <svg width="146" height="40" viewBox="0 0 146 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="netlify-lockup" data-v-4ee6c329><path d="M22.794 39.79V29.687l.21-.21h2.526l.21.21V39.79l-.21.209h-2.527l-.209-.21ZM22.794 10.314V.21l.21-.209h2.526l.21.21v10.104l-.21.21h-2.527l-.209-.21ZM14.1 32.687h-.347l-1.738-1.738v-.347l3.256-3.26 1.84.004.245.242v1.84L14.1 32.686ZM12.015 9.49v-.35l1.738-1.735h.347l3.256 3.256v1.836l-.246.248h-1.839L12.015 9.49ZM.582 18.524h14.316l.21.21v2.53l-.21.209H.582l-.21-.21v-2.53l.21-.209Z" fill="var(--lockup-lines-fill)" data-v-4ee6c329></path> <path d="M29.005 25.265h-2.526l-.21-.21v-5.912c0-1.054-.412-1.869-1.682-1.895-.654-.016-1.4 0-2.199.033l-.12.12v7.651l-.21.21h-2.526l-.21-.21V14.948l.21-.21h5.684a3.998 3.998 0 0 1 3.998 3.999v6.315l-.21.21v.003ZM41.24 20.841l-.21.21H34.5l-.21.209c0 .422.423 1.685 2.108 1.685.631 0 1.263-.21 1.476-.631l.21-.21h2.525l.21.21c-.21 1.263-1.263 3.16-4.424 3.16-3.58 0-5.265-2.526-5.265-5.477 0-2.952 1.685-5.478 5.055-5.478 3.37 0 5.056 2.526 5.056 5.478v.844Zm-3.161-2.107c0-.21-.21-1.686-1.895-1.686s-1.895 1.476-1.895 1.686l.21.21h3.37l.21-.21ZM47.136 22.104c0 .422.21.632.632.632h1.895l.209.209v2.107l-.21.21h-1.894c-1.895 0-3.58-.845-3.58-3.161v-4.634l-.21-.21h-1.475l-.21-.209v-2.107l.21-.21h1.476l.21-.209v-1.894l.209-.21h2.526l.21.21v1.894l.209.21h2.316l.21.21v2.106l-.21.21h-2.316l-.21.21V22.1l.003.003ZM54.93 25.265h-2.525l-.21-.21V10.73l.21-.21h2.526l.21.21v14.322l-.21.21v.003ZM60.618 13.046h-2.526l-.21-.209V10.73l.21-.21h2.526l.21.21v2.107l-.21.21Zm0 12.22h-2.526l-.21-.21V14.944l.21-.21h2.526l.21.21v10.112l-.21.21ZM70.52 10.73v2.107l-.21.21h-1.894c-.422 0-.632.209-.632.631v.844l.21.21H70.1l.21.21v2.106l-.21.21h-2.107l-.21.21v7.581l-.21.21H65.05l-.21-.21v-7.582l-.21-.21h-1.475l-.21-.209v-2.107l.21-.21h1.476l.21-.209v-.844c0-2.317 1.684-3.161 3.58-3.161h1.894l.21.21-.004.003ZM78.311 25.474c-.844 2.108-1.685 3.37-4.633 3.37h-1.054l-.21-.209v-2.107l.21-.21h1.054c1.053 0 1.263-.209 1.475-.84v-.21l-3.37-8.216v-2.108l.21-.21h1.894l.21.21 2.526 7.163h.21l2.525-7.163.21-.21h1.894l.21.21v2.108l-3.37 8.426.01-.004Z" fill="var(--lockup-wordmark-fill)" data-v-4ee6c329></path> <path d="M94.699 25.205V10.707l-.213-.214H92.78l-.213.214v5.117h-.213c-.661-.853-1.706-1.28-2.772-1.28-2.985 0-4.69 2.346-4.69 5.544 0 3.198 1.705 5.543 4.69 5.543 1.13 0 2.132-.469 2.772-1.28h.213l.213.854.213.213h1.493l.213-.213Zm-2.132-5.117c0 2.558-1.066 3.624-2.772 3.624-1.705 0-2.771-1.258-2.771-3.624 0-2.367 1.066-3.625 2.771-3.625 1.706 0 2.772 1.066 2.772 3.625ZM96.614 20.088c0 3.411 1.918 5.543 5.117 5.543 3.198 0 5.117-2.132 5.117-5.543 0-3.412-1.919-5.544-5.117-5.544s-5.117 2.133-5.117 5.544Zm2.132 0c0-2.346 1.066-3.625 2.985-3.625 1.918 0 2.985 1.28 2.985 3.625 0 2.345-1.067 3.624-2.985 3.624-1.92 0-2.985-1.279-2.985-3.624ZM110.26 20.088c0-2.346 1.066-3.625 2.985-3.625 1.705 0 2.345.853 2.558 1.706l.213.213h1.706l.213-.213c-.213-1.919-1.706-3.625-4.69-3.625-3.199 0-5.117 2.133-5.117 5.544 0 3.411 1.918 5.543 5.117 5.543 2.984 0 4.477-1.706 4.69-3.624l-.213-.213h-1.706l-.213.213c-.213.852-.853 1.705-2.558 1.705-1.919 0-2.985-1.279-2.985-3.624ZM127.733 22.433c0-1.919-1.066-2.772-3.199-3.198-2.132-.426-2.984-.64-2.984-1.706 0-.852.852-1.066 1.918-1.066 1.493 0 1.919.64 1.919 1.28l.214.213h1.705l.213-.213c0-2.132-1.705-3.198-4.051-3.198-2.984 0-4.05 1.492-4.05 2.984 0 1.92 1.279 2.772 3.411 3.198 2.132.427 2.772.64 2.772 1.706 0 .853-.64 1.28-2.133 1.28-1.492 0-2.132-.64-2.132-1.706l-.213-.213h-1.705l-.214.213c0 2.345 1.493 3.624 4.264 3.624 2.985 0 4.265-1.492 4.265-3.198Z" fill="var(--lockup-secondary-text-fill)" data-v-4ee6c329></path> <path d="M131.138 18.524h14.316l.209.21v2.53l-.209.209h-14.316l-.21-.21v-2.53l.21-.209Z" fill="var(--lockup-lines-fill)" data-v-4ee6c329></path></svg></a></div> <div class="navbar__actions-wrapper"><form id="search-form" role="search" class="algolia-search-wrapper search-form"><label class="search-form__label"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32" class="search-form__label-icon-search"><path d="M20.571 15.143c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8 8-3.589 8-8zM29.714 30c0 1.25-1.036 2.286-2.286 2.286-0.607 0-1.196-0.25-1.607-0.679l-6.125-6.107c-2.089 1.446-4.589 2.214-7.125 2.214-6.946 0-12.571-5.625-12.571-12.571s5.625-12.571 12.571-12.571 12.571 5.625 12.571 12.571c0 2.536-0.768 5.036-2.214 7.125l6.125 6.125c0.411 0.411 0.661 1 0.661 1.607z" fill="rgba(175, 180, 182, 0.87)"></path></svg> <input id="algolia-search-input" placeholder="Search our docs by topic..." class="search-form__input"></label> <button tabindex="-1" type="reset" class="search-form__label-icon-close"><span class="visuallyhidden">Close search</span> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18"><g fill="#A3A9AC" transform="scale(-1 1) rotate(45 .571 -12.959)"><rect width="2.333" height="18.667" x="8.164" y=".003"></rect> <polygon points="8.164 .003 10.497 .003 10.497 18.67 8.164 18.67" transform="rotate(-90 9.33 9.336)"></polygon></g></svg></button> <div class="search-form__content-overlay"></div></form> <div class="navbar__right-actions"><a href="/ask-netlify/" aria-label="ask netlify" class="navbar__ask-netlify-link"><span class="navbar__ask-netlify-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 44 44" class="wrapper__icon-ask-netlify"><path fill="currentColor" d="M18.77 23.56a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0Zm8.26 1.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6Zm-3.86-1.54.03.07v.38l-.03.07-.87 1.77-.12.09h-.32l-.13-.1-.9-1.76-.03-.07v-.38l.03-.07 1-.66h.31l1.03.66Z"></path> <path fill="currentColor" fill-rule="evenodd" d="M22.32 13C28.77 13 34 17.22 34 23.67a6.97 6.97 0 0 1-6.97 6.97H10v-6.97C10 17.22 15.23 13 21.68 13h.64ZM11.55 23.16a5.24 5.24 0 0 1 10.07-2.05h.76l.01-.03a5.24 5.24 0 0 1 10.06 2.08c0 2.65-2.13 5.17-4.53 5.23H16.5a5.24 5.24 0 0 1-4.95-5.23Z" clip-rule="evenodd"></path> <path fill="currentColor" d="m24.47 8.12.07-.16 1.16-.4.15.08.63 1.95-.4.82-.16.06-.82-.4-.63-1.95Zm9.88 3.27.16.06.48 1.13-.07.16-1.9.76-.85-.34-.07-.16.35-.85 1.9-.76ZM30.04 8l.16-.06 1.1.54.05.16-1.14 2.43-.87.3-.15-.08-.3-.86L30.04 8Z" class="ask-netlify-flair"></path></svg></span> <span class="navbar__ask-netlify-label">Ask Netlify</span></a> <div class="user-menu"><!----> <button href="#menu" aria-label="menu" class="menu-trigger is-not-visible-mamabear"><svg viewBox="0 0 31 25" xmlns="http://www.w3.org/2000/svg" class="wrapper__icon-menu"><rect x="0.581177" y="0.71875" width="30" height="4" fill="currentcolor"></rect> <rect x="0.581177" y="10.7188" width="30" height="4" fill="currentcolor"></rect> <rect x="0.581177" y="20.7188" width="30" height="4" fill="currentcolor"></rect></svg></button> <nav aria-label="Netlify navigation" class="navbar__nav is-visible-mamabear navbar__authlinks" data-v-1733a580><div class="navbar__nav-list" data-v-1733a580><a href="https://app.netlify.com/login" rel="noopener noreferrer" class="navbar__nav-link" data-v-1733a580> Log in </a> <a href="https://app.netlify.com/signup" target="self" rel="noopener noreferrer" class="navbar__nav-link signup-button" data-v-1733a580> Sign up </a></div></nav></div></div></div></div></header> <main class="wrapper wrapper--main"><div class="wrapper__sidebar wrapper__navigation"><a class="button button--icon button--close is-not-visible-mamabear"><svg aria-hidden="true" width="24" height="24" viewBox="0 0 16 16" class="icon"><path d="M8,15 C4.13400675,15 1,11.8659932 1,8 C1,4.13400675 4.13400675,1 8,1 C11.8659932,1 15,4.13400675 15,8 C15,11.8659932 11.8659932,15 8,15 Z M10.44352,10.7233105 L10.4528296,10.7326201 L10.7326201,10.4528296 C11.0310632,10.1543865 11.0314986,9.66985171 10.7335912,9.37194437 L9.36507937,8.0034325 L10.7360526,6.63245928 C11.0344957,6.33401613 11.0349311,5.84948135 10.7370237,5.55157401 L10.448426,5.26297627 C10.1505186,4.96506892 9.66598387,4.96550426 9.36754072,5.26394741 L8.00589385,6.62559428 L6.63738198,5.25708241 C6.33947464,4.95917507 5.85493986,4.95961041 5.55649671,5.25805356 L5.26737991,5.54717036 C4.96893676,5.84561351 4.96850142,6.33014829 5.26640876,6.62805563 L6.62561103,7.9872579 L5.25463781,9.35823112 C4.95619466,9.65667427 4.95575932,10.141209 5.25366666,10.4391164 L5.5422644,10.7277141 C5.84017175,11.0256215 6.32470652,11.0251861 6.62314967,10.726743 L7.99412289,9.35576976 L9.36263476,10.7242816 C9.66054211,11.022189 10.1450769,11.0217536 10.44352,10.7233105 Z"></path></svg></a> <div aria-label="Docs" class="sidebar wrapper__sidebar-interior"><nav aria-label="Docs"><div><div class="sidebar__section"><span class="sidebar__section-label">Welcome</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/" aria-current="page" class="sidebar__link">Home</a></div></li><li class="sidebar__link-item"><div><a href="/get-started/" class="sidebar__link">Get started</a></div></li><li class="sidebar__link-item"><div><a href="/welcome/add-new-site/" class="sidebar__link">Add new site</a></div></li><li class="sidebar__link-item"><div><a href="/welcome/build-with-ai/" class="sidebar__link">Build with AI</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Get help </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Platform</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/platform/what-is-netlify/" class="sidebar__link">What is Netlify?</a></div></li><li class="sidebar__link-item"><div><a href="/platform/who-is-netlify-for/" class="sidebar__link">Who is Netlify for?</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Checklists </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> How we release </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Platform primitives</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/platform/primitives/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Functions </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Edge Functions </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Image CDN </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/blobs/overview/" class="sidebar__link">Blobs</a></div></li><li class="sidebar__link-item"><div><a href="/platform/caching/" class="sidebar__link">Caching</a></div></li><li class="sidebar__link-item"><div><a href="/platform/dev-server/" class="sidebar__link">Dev Server</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Platform extensions </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Frameworks</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/frameworks/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Framework support </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/frameworks/environment-variables/" class="sidebar__link">Use environment variables with frameworks</a></div></li><li class="sidebar__link-item"><div><a href="/frameworks-api/" class="sidebar__link">Frameworks API</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Developer tools</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button aria-expanded="true" tabIndex="-1" class="sidebar__group-heading open"> CLI </button> <ul class="sidebar__links sidebar__group-items"><li class="sidebar__link-item"><div><a href="/cli/get-started/" aria-current="page" class="active sidebar__link">Get started</a></div></li><li class="sidebar__link-item"><div><a href="/cli/local-development/" class="sidebar__link">Local development</a></div></li><li class="sidebar__link-item"><div><a href="/cli/manage-functions/" class="sidebar__link">Manage functions</a></div></li><li class="sidebar__link-item"><div><a href="/cli/debug-with-vscode/" class="sidebar__link">Debug with VSCode</a></div></li><li class="sidebar__link-item"><div><a href="https://cli.netlify.com" target="_blank" rel="noopener noreferrer" class="sidebar__link">Command reference</a></div></li></ul> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> API </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/terraform-provider/" class="sidebar__link">Terraform Provider</a></div></li><li class="sidebar__link-item"><div><a href="https://developers.netlify.app/sdk/get-started/introduction/" target="_blank" rel="noopener noreferrer" class="sidebar__link">Netlify SDK</a></div></li><li class="sidebar__link-item"><div><a href="/welcome/command-palette/" class="sidebar__link">Command Palette</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Integrate &amp; extend</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/integrations/overview/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Integrations </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Build Plugins </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/slack-app/" class="sidebar__link">Netlify App for Slack</a></div></li><li class="sidebar__link-item"><div><a href="/integrations/extend-netlify/" class="sidebar__link">Extend Netlify</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Configure &amp; deploy site</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Git </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Environment variables </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Configure builds </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Site deploys </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Domains &amp; HTTPS </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Static routing </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Forms </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Visual editing</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Visual Editor </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/ai-assisted-publishing/" class="sidebar__link">AI-Assisted Publishing</a></div></li><li class="sidebar__link-item"><div><a href="https://visual-editor-reference.netlify.com/" target="_blank" rel="noopener noreferrer" class="sidebar__link">Visual editor reference</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Manage data</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Connect </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Site &amp; team management</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Accounts &amp; billing </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Security </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Monitor sites </button> <!----> <!----></section></li></ul></div></div></nav> <div aria-labelledby="#external-link__header" class="external-links" data-v-bad94b42><p id="external-link__header" class="external-links__header" data-v-bad94b42> Contact </p> <ul class="external-links__list" data-v-bad94b42><li class="external-links__item" data-v-bad94b42><a href="https://answers.netlify.com" target="_blank" rel="noopener noreferrer" class="external-links__link" data-v-bad94b42> Forums </a></li> <li class="external-links__item" data-v-bad94b42><a href="https://www.netlify.com/support/" target="_blank" rel="noopener noreferrer" class="external-links__link" data-v-bad94b42> Contact support </a></li></ul></div> <nav aria-label="Netlify navigation" class="navbar__nav is-visible-mamabear navbar__authlinks is-not-visible-mamabear" data-v-1733a580><div class="navbar__nav-list" data-v-1733a580><a href="https://app.netlify.com/login" rel="noopener noreferrer" class="navbar__nav-link" data-v-1733a580> Log in </a> <a href="https://app.netlify.com/signup" target="self" rel="noopener noreferrer" class="navbar__nav-link signup-button" data-v-1733a580> Sign up </a></div></nav></div></div> <div class="wrapper__sidebar wrapper__toc"><nav aria-label="On this page" data-toc="" class="contents wrapper__sidebar-interior"> <details><summary class="contents__header">On this page</summary> <ol><li><a href="/cli/get-started/#installation" data-slug="installation">Installation</a> <ul><li><a href="/cli/get-started/#installation-in-a-ci-environment" data-slug="installation-in-a-ci-environment">Installation in a CI environment</a> <!----></li></ul></li><li><a href="/cli/get-started/#authentication" data-slug="authentication">Authentication</a> <ul><li><a href="/cli/get-started/#obtain-a-token-with-the-command-line" data-slug="obtain-a-token-with-the-command-line">Obtain a token with the command line</a> <ul></ul></li><li><a href="/cli/get-started/#obtain-a-token-in-the-netlify-ui" data-slug="obtain-a-token-in-the-netlify-ui">Obtain a token in the Netlify UI</a> <!----></li><li><a href="/cli/get-started/#cancel-access-tokens" data-slug="cancel-access-tokens">Cancel access tokens</a> <!----></li></ul></li><li><a href="/cli/get-started/#usage-data-collection" data-slug="usage-data-collection">Usage data collection</a> <!----></li><li><a href="/cli/get-started/#continuous-deployment" data-slug="continuous-deployment">Continuous deployment</a> <ul><li><a href="/cli/get-started/#automated-setup" data-slug="automated-setup">Automated setup</a> <!----></li><li><a href="/cli/get-started/#manual-setup" data-slug="manual-setup">Manual setup</a> <ul></ul></li></ul></li><li><a href="/cli/get-started/#run-a-local-development-environment" data-slug="run-a-local-development-environment">Run a local development environment</a> <!----></li><li><a href="/cli/get-started/#run-builds-locally" data-slug="run-builds-locally">Run builds locally</a> <!----></li><li><a href="/cli/get-started/#manual-deploys" data-slug="manual-deploys">Manual deploys</a> <ul><li><a href="/cli/get-started/#deploy-directories" data-slug="deploy-directories">Deploy directories</a> <!----></li><li><a href="/cli/get-started/#draft-deploys" data-slug="draft-deploys">Draft deploys</a> <!----></li><li><a href="/cli/get-started/#production-deploys" data-slug="production-deploys">Production deploys</a> <!----></li><li><a href="/cli/get-started/#node-js-function-dependencies" data-slug="node-js-function-dependencies">Node.js function dependencies</a> <!----></li></ul></li><li><a href="/cli/get-started/#link-and-unlink-sites" data-slug="link-and-unlink-sites">Link and unlink sites</a> <ul><li><a href="/cli/get-started/#link-with-an-environment-variable" data-slug="link-with-an-environment-variable">Link with an environment variable</a> <!----></li></ul></li><li><a href="/cli/get-started/#manage-environment-variables" data-slug="manage-environment-variables">Manage environment variables</a> <ul><li><a href="/cli/get-started/#create-or-update-environment-variables" data-slug="create-or-update-environment-variables">Create or update environment variables</a> <!----></li><li><a href="/cli/get-started/#get-environment-variables" data-slug="get-environment-variables">Get environment variables</a> <!----></li><li><a href="/cli/get-started/#delete-environment-variables" data-slug="delete-environment-variables">Delete environment variables</a> <!----></li></ul></li><li><a href="/cli/get-started/#work-with-monorepos" data-slug="work-with-monorepos">Work with monorepos</a> <!----></li><li><a href="/cli/get-started/#print-debugging-output" data-slug="print-debugging-output">Print debugging output</a> <!----></li><li><a href="/cli/get-started/#get-help" data-slug="get-help">Get help</a> <!----></li></ol></details></nav></div> <section class="wrapper__content"><header class="content__default"><div class="wrapper__breadcrumbs"><span class="breadcrumb__item"><span>Developer tools</span> <span class="breadcrumb__break">/</span></span><span class="breadcrumb__item"><span>CLI</span> <span class="breadcrumb__break">/</span></span></div> <h1>Get started with Netlify CLI</h1></header> <div class="content__default"><p>Netlify’s command line interface (CLI) lets you configure <a href="#continuous-deployment">continuous deployment</a> straight from the command line. You can use Netlify CLI to <a href="/cli/local-development/">run a local development server</a> that you can share with others, <a href="#run-builds-locally">run a local build and plugins</a>, and <a href="#manual-deploys">deploy your site</a>.</p> <p>The sections below describe how to perform common tasks with Netlify CLI. You can also access a <a href="https://cli.netlify.com" target="_blank" rel="noopener noreferrer">full command reference</a> online, or get help <a href="/cli/get-started/#get-help">within Netlify CLI</a>.</p> <h2 id="installation"><a href="#installation" class="header-anchor">#</a> Installation</h2> <p>To install Netlify CLI, make sure you have <a href="https://nodejs.org/en/download/" target="_blank" rel="noopener noreferrer">Node.js</a> version 18.14.0 or later.</p> <p>Then, run this command from any directory in your terminal:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">npm</span> <span class="token function">install</span> netlify-cli <span class="token parameter variable">-g</span> </code></pre></div><p>This installs Netlify CLI globally, so you can run <code>netlify</code> commands from any directory. You can check the version and find out some basic information about the tool with the following command:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify </code></pre></div><div class="custom-block netlify-tip"><p class="custom-block-title">Global versus local</p> <p>Installing Netlify CLI globally means that your system always has the latest version, including any breaking changes. While global installation is appropriate for initial development and experimentation, for managing builds in a continuous integration (CI) environment, use <a href="#installation-in-a-ci-environment">local CLI installation</a> instead.</p></div> <h3 id="installation-in-a-ci-environment"><a href="#installation-in-a-ci-environment" class="header-anchor">#</a> Installation in a CI environment</h3> <p>When using Netlify CLI in a continuous integration (CI) environment such as GitHub Actions, CircleCI, or Travis CI, we recommend installing it locally as a development dependency instead of globally. This binds a specific CLI version to your project repository. To install Netlify CLI locally, run the following command from the root directory of your project:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">npm</span> <span class="token function">install</span> netlify-cli --save-dev </code></pre></div><p>For CI environments, we also recommend using a <a href="https://docs.npmjs.com/cli/v7/commands/npm-ci" target="_blank" rel="noopener noreferrer">lock file</a> to guarantee reproducible builds and relying on an automated tool like <a href="https://github.com/renovatebot/renovate" target="_blank" rel="noopener noreferrer">renovate</a> or <a href="https://dependabot.com/" target="_blank" rel="noopener noreferrer">dependabot</a> to manage Netlify CLI version updates.</p> <h2 id="authentication"><a href="#authentication" class="header-anchor">#</a> Authentication</h2> <p>Netlify CLI uses an access token to authenticate with Netlify. You can obtain this token using the command line or in the Netlify UI.</p> <div class="custom-block netlify-tip"><p class="custom-block-title">SAML SSO</p> <p>If your team requires you to log in with <a href="/security/secure-netlify-access/configure-team-saml-sso/">single sign-on (SSO)</a>, your tokens will be denied access to the team by default. You can choose to grant access to the team when you obtain a new token. You must be logged in to the team with SSO to grant access to it.</p></div> <div id="command-line-login" class="legacy-anchor"></div> <div id="obtain-a-token-via-the-command-line" class="legacy-anchor"></div> <h3 id="obtain-a-token-with-the-command-line"><a href="#obtain-a-token-with-the-command-line" class="header-anchor">#</a> Obtain a token with the command line</h3> <p>To authenticate and obtain an access token using the command line, enter the following command from any directory:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify login </code></pre></div><p>This will open a browser window, asking you to log in with Netlify and grant access to <strong>Netlify CLI</strong>.</p> <p><img src="/images/cli-authorize-ui.png" alt=""></p> <p>Once authorized, Netlify CLI stores your access token in a <a href="#config-json-location"><code>config.json</code></a> global configuration file. The Netlify CLI uses the token in this file automatically for all future commands.</p> <h4 id="config-json-location"><a href="#config-json-location" class="header-anchor">#</a> <code>config.json</code> location</h4> <p>You can find the Netlify CLI global configuration file, <code>config.json</code>, under your user in these OS-specific locations:</p> <ul><li>macOS: <code>Library/Preferences/netlify/config.json</code></li> <li>Linux: <code>.config/netlify/config.json</code></li> <li>Windows: <code>AppData\Roaming\netlify\Config\config.json</code></li></ul> <h3 id="obtain-a-token-in-the-netlify-ui"><a href="#obtain-a-token-in-the-netlify-ui" class="header-anchor">#</a> Obtain a token in the Netlify UI</h3> <p>You can generate a personal access token (PAT) manually in your Netlify user settings:</p> <ol><li>Go to <div aria-label="Navigation path" class="nav-path-container"><strong> Applications <span aria-hidden="true">></span> Personal access tokens</strong></div>.</li> <li>Select <strong>New access token</strong>.</li> <li>Enter a descriptive name to help you remember what the token will be used for.</li> <li>Select <strong>Allow access to my SAML-based Netlify team</strong> to authorize access to your SAML-based team data through the API.</li> <li>Select an <strong>Expiration</strong> date for your token to help keep your information secure.</li> <li>Select <strong>Generate token</strong>.</li> <li>Copy the token to your clipboard and store it in a safe location. Once you navigate away from this page, you won’t be able to access the value again.</li> <li>Select <strong>Done</strong>.</li> <li>Save the token as a <code>NETLIFY_AUTH_TOKEN</code> environment variable in your terminal settings or in the UI of a Continuous Integration (CI) tool.</li></ol> <div id="revoking-access" class="legacy-anchor"></div> <h3 id="cancel-access-tokens"><a href="#cancel-access-tokens" class="header-anchor">#</a> Cancel access tokens</h3> <p>To revoke your user access token for Netlify CLI, go to your Netlify user <a href="https://app.netlify.com/user/applications" target="_blank" rel="noopener noreferrer"><strong>Applications settings</strong></a>. The procedure for revoking access depends on how access was granted.</p> <ul><li>For access granted using the <code>netlify login</code> command, scroll to the <a href="https://app.netlify.com/user/applications#authorized-applications" target="_blank" rel="noopener noreferrer"><strong>Authorized applications</strong></a> section, and find <strong>Netlify CLI</strong>. Select <div aria-label="Navigation path" class="nav-path-container"><strong>Options <span aria-hidden="true">></span> Revoke access</strong></div>.</li> <li>If you manually created a <a href="/cli/get-started/#obtain-a-token-in-the-netlify-ui">personal access token</a>, you can find it in the <a href="https://app.netlify.com/user/applications#personal-access-tokens" target="_blank" rel="noopener noreferrer"><strong>Personal access tokens</strong></a> section. Select <div aria-label="Navigation path" class="nav-path-container"><strong>Options <span aria-hidden="true">></span> Delete personal token</strong></div>.</li></ul> <h2 id="usage-data-collection"><a href="#usage-data-collection" class="header-anchor">#</a> Usage data collection</h2> <p>By default, Netlify collects data on usage of Netlify CLI commands. We do this to improve the reliability and performance of Netlify CLI, and to help drive new features and improvements.</p> <p>If you’d like to opt out of sending usage data, you can do so by editing the <code>telemetryDisabled</code> property in the Netlify CLI <a href="#config-json-location"><code>config.json</code></a>. You can also do this with the command line:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># opt out of sharing usage data</span> netlify --telemetry-disable <span class="token comment"># allow your usage to help shape development</span> netlify --telemetry-enable </code></pre></div><h2 id="continuous-deployment"><a href="#continuous-deployment" class="header-anchor">#</a> Continuous deployment</h2> <p>With <a href="/site-deploys/create-deploys/#deploy-with-git">continuous deployment</a>, Netlify will automatically deploy new versions of your site when you push commits to your connected Git repository. This also facilitates features like <a href="/site-deploys/deploy-previews/">Deploy Previews</a>, branch deploys, and <a href="/site-deploys/split-testing/">split testing</a>. (Some of these features must be enabled in the Netlify UI.)</p> <div class="custom-block netlify-tip"><p class="custom-block-title"><span>To connect your local project to an existing Netlify site, use <code>link</code></span></p> <p>If your site already has continuous deployment set up and you just want to associate a project on your local machine to an existing site on Netlify, use <a href="#link-and-unlink-sites"><code>netlify link</code></a> instead of <code>netlify init</code> or <code>netlify init --manual</code>.</p></div> <h3 id="automated-setup"><a href="#automated-setup" class="header-anchor">#</a> Automated setup</h3> <p>For repositories stored on GitHub.com, you can use Netlify CLI to connect your repository by running the following command from your local repository:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify init </code></pre></div><p>In order to connect your repository for continuous deployment, Netlify CLI will need access to create a deploy key and a webhook on the repository. When you run the command above, you’ll be prompted to log in to your GitHub account, which will create an account-level access token.</p> <p>The access token will be stored in the Netlify CLI <a href="#config-json-location"><code>config.json</code></a>. Your login password will never be stored. You can revoke the access token at any time from your GitHub account settings; however, this will disable continuous deployment on all sites that were configured with that access token.</p> <h3 id="manual-setup"><a href="#manual-setup" class="header-anchor">#</a> Manual setup</h3> <p>For repositories stored on GitLab, Bitbucket, or Azure DevOps, you can connect your repository manually with the <code>--manual</code> flag.</p> <p>For repositories on GitHub, you can also connect your repository manually, if you prefer to give more limited, repository-only access for your repositories on GitHub.</p> <p>From your local repository, run the following command:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify init <span class="token parameter variable">--manual</span> </code></pre></div><p>The Netlify CLI will prompt you to set your deploy settings and then provide you with a deploy/access key and a webhook URL. You’ll need to manually add the key and webhook URL to your Git provider.</p> <h4 id="add-your-deploy-or-access-key"><a href="#add-your-deploy-or-access-key" class="header-anchor">#</a> Add your deploy or access key</h4> <p>Netlify uses a deploy or access key to fetch your repository using ssh for building and deploying. The deploy key does not require write access.</p> <p><img src="/images/cli-deploy-key.png" alt="Sample terminal output reads: 'Give this Netlify SSH public key access to your repository,' and displays a key code."></p> <p>Copy the key printed in the command line, then add it to your Git provider.</p> <ul><li><strong>GitHub, GitLab, or Bitbucket.</strong> Add the deploy key to your repository’s settings. If you have more than one site connected to a repository, you will need a unique key for each repository.</li> <li><strong>Azure DevOps.</strong> Add the Netlify SSH public key to your Azure DevOps user settings under <strong>SSH Public Keys</strong>.</li></ul> <h4 id="add-your-webhook-url"><a href="#add-your-webhook-url" class="header-anchor">#</a> Add your webhook URL</h4> <p>Your Git provider will send a message to this webhook when you push changes to your repository, triggering a new deploy on Netlify.</p> <p><img src="/images/cli-webhook.png" alt="Sample terminal output reads: 'Configure the following webhook for your repository,' and displays a URL."></p> <p>Copy the webhook address printed in the command line, then add the URL and webhook details to your Git provider. If available, the <strong>Content type</strong> should be set to <code>application/json</code>.</p> <ul><li><p><strong>GitHub, GitLab, or Bitbucket.</strong> Add the webhook address as the Payload URL for a new webhook in your repository’s settings. When selecting events to trigger the webhook, <strong>Push</strong> events will trigger production and branch deploys on watched branches, and <strong>Pull/Merge request</strong> events will trigger deploy previews.</p></li> <li><p><strong>Azure DevOps.</strong> In your project’s settings under <strong>Service hooks</strong>, add webhooks for these Azure DevOps events using the Netlify webhook address as the Payload URL:</p> <ul><li>Code pushed</li> <li>Pull request created</li> <li>Pull request merge attempted</li> <li>Pull request updated</li></ul> <p>Ensure that you set webhooks for your repository with the default <code>[Any]</code> branch setting. Once configured, these webhook events can trigger production and branch deploys on your watched branches.</p></li></ul> <div id="netlify-dev-beta" class="legacy-anchor"></div> <div id="netlify-dev" class="legacy-anchor"></div> <h2 id="run-a-local-development-environment"><a href="#run-a-local-development-environment" class="header-anchor">#</a> Run a local development environment</h2> <p><a href="https://www.netlify.com/products/dev" target="_blank" rel="noopener noreferrer">Netlify Dev</a> brings the functionality of your Netlify production environment directly to your local machine.</p> <p>For more information on how to configure and use Netlify Dev, refer to our <a href="/cli/local-development">local development with Netlify Dev</a> doc.</p> <h2 id="run-builds-locally"><a href="#run-builds-locally" class="header-anchor">#</a> Run builds locally</h2> <p>You can run builds in Netlify CLI to mimic the behavior of running a build on Netlify — including <a href="/build-plugins/">Build Plugins</a>. To execute a build locally, run the following command from the root of your linked repository:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify build </code></pre></div><p>The command will build your project using <a href="/environment-variables/overview/">environment variables</a> set in <code>netlify.toml</code> and those set using the Netlify UI, CLI, or API. Note that environment variables apply to all scopes when running <code>netlify build</code> locally.</p> <div class="custom-block netlify-warning"><p class="custom-block-title">Make sure your Node.js versions match</p> <p>If you are using the Netlify CLI to run a build locally, make sure the Node.js version installed in your local environment matches the version <a href="/configure-builds/manage-dependencies/#node-js-and-javascript">set for your build on Netlify</a>. If the versions don’t match, you may encounter errors.</p></div> <p>If you’d like to get a summary of what a build will do without taking the time to do a full build, you can use the <code>--dry</code> flag:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify build <span class="token parameter variable">--dry</span> </code></pre></div><p>This command will output a list of all the stages of the build and the behaviors that are configured to run during each stage.</p> <p>The default deploy context is <code>production</code> but you can also use the <code>--context</code> flag to run a build for a different <a href="/site-deploys/overview/#deploy-contexts">deploy context</a>.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify build <span class="token parameter variable">--context</span> deploy-preview </code></pre></div><p>This command will run the build as if it is a Deploy Preview, applying any settings and environment variable values specific to that context.</p> <h2 id="manual-deploys"><a href="#manual-deploys" class="header-anchor">#</a> Manual deploys</h2> <p>It’s also possible to deploy a site manually, without continuous deployment. This method uploads files directly from your local project directory to your site on Netlify. If <a href="/configure-builds/stop-or-activate-builds/">builds are stopped</a>, manual deploys are the only way you can update your site.</p> <p>A common use case for this command is when you’re using a separate Continuous Integration (CI) tool, deploying prebuilt files to Netlify at the end of the CI tool tasks.</p> <p>To get started with manual deploys, run the following command from your project directory:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify deploy </code></pre></div><p>The first time you run the command, Netlify CLI will prompt you to select an existing site or create a new one, linking the site for all future deploys.</p> <p>The following sections describe the requirements and options for manual deploys.</p> <h3 id="deploy-directories"><a href="#deploy-directories" class="header-anchor">#</a> Deploy directories</h3> <p>The <code>deploy</code> command needs to know which folder to publish. If your project includes serverless functions, it needs to know the location of the <a href="/functions/optional-configuration/#directory">functions folder</a> as well. Netlify CLI will look for this information in three places, in the following order:</p> <ul><li>in <a href="https://cli.netlify.com/deploy" target="_blank" rel="noopener noreferrer">flags</a> specified in the command itself.</li> <li>in a <a href="/configure-builds/file-based-configuration/">netlify.toml file</a> stored at the root of your project directory.</li> <li>in your site configuration in the Netlify UI, if continuous deployment is set up for the site.</li></ul> <p>Here is an example using command flags to set the publish folder and functions folder:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify deploy <span class="token parameter variable">--dir</span><span class="token operator">=</span>_site <span class="token parameter variable">--functions</span><span class="token operator">=</span>functions </code></pre></div><p>In both cases, folder paths are relative to the current directory. Note that paths starting with <code>/</code> will begin at the computer’s root directory — not the base of your project directory.</p> <div id="draft-and-production-deploys" class="legacy-anchor"></div> <h3 id="draft-deploys"><a href="#draft-deploys" class="header-anchor">#</a> Draft deploys</h3> <p>By default, the <code>deploy</code> command deploys to a unique <em>draft</em> URL for previewing and testing.</p> <p><img src="/images/cli-draft-deploy.png" alt=""></p> <p>The default draft URL uses random alphanumeric characters for the subdomain. To customize the subdomain of your draft URL with a unique string, use the <code>--alias</code> flag with the <code>deploy</code> command.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify deploy <span class="token parameter variable">--alias</span><span class="token operator">=</span>YOUR_ALIAS </code></pre></div><p><img src="/images/cli-draft-deploy-alias.png" alt=""></p> <div class="custom-block netlify-warning"><p class="custom-block-title"><span> Avoid using <code>--alias</code> with any of your branch names</span></p> <p>Ensure the string you use after <code>--alias=</code> doesn’t match any existing branch names from your site’s repository. The <code>--alias</code> flag is designed to support draft deploy URLs only and doesn’t create a <a href="/site-deploys/overview/#branches-and-deploys">branch deploy</a> or support our <a href="/domains-https/custom-domains/multiple-domains/#branch-subdomains">branch subdomains</a> feature. Learn more about this flag in the <a href="https://cli.netlify.com/commands/deploy/" target="_blank" rel="noopener noreferrer">CLI reference docs</a>. To create a branch deploy, use <a href="#continuous-deployment">continuous deployment</a>.</p></div> <h3 id="production-deploys"><a href="#production-deploys" class="header-anchor">#</a> Production deploys</h3> <p>To do a <em>production</em> deploy to your main site URL, use the <code>--prod</code> flag (or <code>-p</code> for short):</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify deploy <span class="token parameter variable">--prod</span> </code></pre></div><div id="unbundled-javascript-function-deploys" class="legacy-anchor"></div> <div id="javascript-function-dependencies" class="legacy-anchor"></div> <h3 id="node-js-function-dependencies"><a href="#node-js-function-dependencies" class="header-anchor">#</a> Node.js function dependencies</h3> <p>Before manually deploying TypeScript or JavaScript functions with Netlify CLI, populate <code>node_modules</code> folders with your dependencies by running the following command in any folder containing <code>package.json</code>.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="npm-command-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-sh extra-class" data-v-12d54b40><pre class="language-sh" data-v-12d54b40><code data-v-12d54b40><span class="token function" data-v-12d54b40>npm</span> <span class="token function" data-v-12d54b40>install</span> </code></pre></div></div> <div role="tabpanel" id="yarn-command-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-sh extra-class" data-v-12d54b40><pre class="language-sh" data-v-12d54b40><code data-v-12d54b40><span class="token function" data-v-12d54b40>yarn</span> </code></pre></div></div></div> <p>When you deploy TypeScript or JavaScript functions using the <code>netlify deploy</code> command, Netlify CLI parses each function file to note its dependencies. For each function, the CLI then pulls the required dependencies from the associated <code>node_modules</code> folder and zips them with the function file for deployment.</p> <div id="linking-and-unlinking-sites" class="legacy-anchor"></div> <h2 id="link-and-unlink-sites"><a href="#link-and-unlink-sites" class="header-anchor">#</a> Link and unlink sites</h2> <div class="custom-block netlify-tip"><p class="custom-block-title"><span>If your site isn’t already on Netlify, use <code>init</code> or <code>deploy</code> instead</span></p> <p>If your site is not already on Netlify, you need to either set up <a href="#continuous-deployment">continuous deployment</a> or <a href="#manual-deploys">manually deploy</a> the site before you can link your local project to it. If you use the Netlify CLI to deploy your site, the CLI will automatically link the project on your local machine to the site on Netlify.</p></div> <p>If you want to connect your local project or repository to a site already on Netlify, you can skip the initial setup steps above and run the following command from the root of the local directory:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify <span class="token function">link</span> </code></pre></div><p>This will add a <code>siteId</code> field to a new file inside your project folder, at <code>.netlify/state.json</code>. To unlink your folder from the site, you can remove this field, or you can run the following command from inside the project folder:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify unlink </code></pre></div><h3 id="link-with-an-environment-variable"><a href="#link-with-an-environment-variable" class="header-anchor">#</a> Link with an environment variable</h3> <p>Alternatively, you can link to a site by finding the site ID in the Netlify UI, then adding it to your local terminal environment:</p> <ol><li>Go to <div aria-label="Navigation path" class="nav-path-container"><strong>Site configuration <span aria-hidden="true">></span> General <span aria-hidden="true">></span> Site details <span aria-hidden="true">></span> Site information</strong></div>, and copy the value for <strong>Site ID</strong>.</li> <li>Assign the ID to a <code>NETLIFY_SITE_ID</code> environment variable, in your terminal settings or in the UI of a Continuous Integration (CI) tool.</li></ol> <h2 id="manage-environment-variables"><a href="#manage-environment-variables" class="header-anchor">#</a> Manage environment variables</h2> <p>You can create and update site environment variables stored on Netlify with the CLI’s <a href="https://cli.netlify.com/commands/env" target="_blank" rel="noopener noreferrer"><code>env</code> command</a>. Any changes made using the CLI will be reflected in the Netlify UI. Environment variable changes require a build and deploy to take effect.</p> <p>By default, the Netlify CLI deploy context is the <a href="/environment-variables/overview/#value-per-deploy-context">local development context</a> (<code>dev</code>). Unless a different deploy context is specified, CLI commands will get and use variables that have values set specifically for use with the <code>dev</code> deploy context and variables that have a single value for use across <code>all</code> deploy contexts.</p> <p>Use the <code>--context</code> and <code>--scope</code> flags with your CLI commands to set contextual or scope values, or to filter results. You can use both flags in the same command, for example:</p> <div class="language-sh extra-class"><pre class="language-sh"><code>netlify env:set API_KEY someValue <span class="token parameter variable">--scope</span> functions <span class="token parameter variable">--context</span> production branch-deploy netlify env:list <span class="token parameter variable">--scope</span> builds <span class="token parameter variable">--context</span> deploy-preview </code></pre></div><h3 id="create-or-update-environment-variables"><a href="#create-or-update-environment-variables" class="header-anchor">#</a> Create or update environment variables</h3> <p>To create or update a site environment variable on Netlify, use <code>env:set</code> with the key followed by a space and then the value. You can only set one value at a time, but you can specify multiple deploy contexts and scopes in a space-separated list (no commas) using the <code>--context</code> and <code>--scope</code> flags.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:set API_KEY someValue netlify env:set ANOTHER_API_KEY someValue <span class="token parameter variable">--scope</span> builds <span class="token parameter variable">--context</span> dev </code></pre></div><p>If you omit the <code>--scope</code> or <code>--context</code> flags when running the <code>env:set</code> command, the variable is set to all scopes and with the same value for all deploy contexts.</p> <p>To set one value for <code>production</code> and <code>deploy-preview</code> and another value for a branch named <code>staging</code>, run the command twice:</p> <div class="language-sh extra-class"><pre class="language-sh"><code>netlify env:set API_KEY someValue <span class="token parameter variable">--context</span> production deploy-preview netlify env:set API_KEY someOtherValue <span class="token parameter variable">--context</span> branch:staging </code></pre></div><p>You can also import environment variables from a <code>.env</code> file into Netlify using <code>env:import</code> followed by the filename. The imported variables are set to all scopes and with the same value for all deploy contexts.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:import .env </code></pre></div><p>To copy environment variables from one site to another, use <code>env:clone</code>.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:clone <span class="token parameter variable">--to</span> destinationSiteId <span class="token parameter variable">--from</span> sourceSiteID </code></pre></div><p>If you are using environment variable secrets with Netlify’s <a href="/environment-variables/secrets-controller">Secrets Controller</a>, you can flag that an environment variable value is secret using the <code>--secret</code> flag when creating or modifying a value.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:set API_KEY someValue <span class="token parameter variable">--context</span> production <span class="token parameter variable">--secret</span> </code></pre></div><h3 id="get-environment-variables"><a href="#get-environment-variables" class="header-anchor">#</a> Get environment variables</h3> <p>To retrieve a list of site environment variables stored on Netlify, use <code>env:list</code>. The CLI gets all variables that have values set for local development with the Netlify CLI (deploy contexts <code>dev</code> or <code>all</code>) and outputs a list of keys with an option to display their values.</p> <p>You can request other <a href="/environment-variables/overview/#value-per-deploy-context">contextual values</a> using the <code>--context</code> flag and filter the list using the <code>--scope</code> flag. You can also use the <code>--json</code> and <code>--plain</code> flags to retrieve the list in JSON or plain text format, which can be helpful if you want to copy the values into a <code>.env</code> file locally.</p> <p>The list will only include shared environment variables if the command is run by a Team Owner.</p> <p>This list will not include raw, unmasked values of any environment variables marked as secret unless the <code>--context</code> is <code>dev</code>. Review the <a href="/environment-variables/secrets-controller/#environment-variable-secrets-policy">environment variable secrets</a> policy for more details on the access restrictions.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:list netlify env:list <span class="token parameter variable">--context</span> branch:staging netlify env:list <span class="token parameter variable">--scope</span> functions netlify env:list <span class="token parameter variable">--plain</span> </code></pre></div><p>To retrieve an individual environment variable’s value, use <code>env:get</code>. The CLI gets the values set for local development with the Netlify CLI (deploy contexts <code>dev</code> or <code>all</code>). You can use the <code>--context</code> flag to retrieve a value from another context or the <code>--scope</code> flag to retrieve a value only if the variable is available to a specific scope.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:get API_KEY netlify env:get API_KEY <span class="token parameter variable">--context</span> production </code></pre></div><h3 id="delete-environment-variables"><a href="#delete-environment-variables" class="header-anchor">#</a> Delete environment variables</h3> <p>To delete environment variables from Netlify, use <code>env:unset</code>. This command deletes the specified variable and its values from all deploy contexts. Once unset, these variables will no longer be stored on Netlify or appear in the UI. You can use the <code>--context</code> flag to delete one value from a specific deploy context instead.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify env:unset API_KEY netlify env:unset API_KEY <span class="token parameter variable">--context</span> dev </code></pre></div><h2 id="work-with-monorepos"><a href="#work-with-monorepos" class="header-anchor">#</a> Work with monorepos</h2> <div class="custom-block netlify-note"><p class="custom-block-title">Commands execute from the workspace root</p> <p>Starting with Netlify CLI version 16, all commands execute from the workspace root to mimic the build system behavior on Netlify. The workspace root is the directory that contains the highest-level <code>package.json</code> in your monorepo. Make sure any paths declared in <code>netlify.toml</code> are absolute paths relative to the <a href="/configure-builds/overview/#definitions">base directory</a>.</p></div> <p>A monorepo is a repository that contains multiple sites or apps, each in its own subdirectory.</p> <p>When you use the Netlify CLI, Netlify automatically scans the repository to detect if you are using a monorepo. If you are, the Netlify CLI will ask you to specify the site to run a command on and you can choose from the list of detected sites.</p> <p><img src="/images/cli-get-started-monorepos-select.png" alt=""></p> <p>You also have the option to manually set the following flag:</p> <ul><li><p><code>--filter</code>: to specify which site in your monorepo to use for a command. You can use the package name or the path to the package. This way you can run commands directly from the repository root for all projects in your monorepo.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify dev <span class="token parameter variable">--filter</span> website netlify dev <span class="token parameter variable">--filter</span> packages/website </code></pre></div></li></ul> <p>Note that selecting a site with the Netlify CLI only applies to the command you are running and doesn’t influence the <a href="/configure-builds/overview/">build settings</a> in the Netlify UI. Learn more about how to set up a site from a <a href="/configure-builds/monorepos/">monorepo</a>.</p> <h2 id="print-debugging-output"><a href="#print-debugging-output" class="header-anchor">#</a> Print debugging output</h2> <p>To print the full debugging output for a command to the terminal, set the <code>DEBUG</code> variable before running the command.</p> <p>On Mac OS, Linux, and some common Windows terminals, add <code>DEBUG=*</code> to the beginning of the command:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token assign-left variable">DEBUG</span><span class="token operator">=</span>* netlify deploy </code></pre></div><p>If you are using the Windows command prompt (cmd.exe), use <code>set</code> to set the variable:</p> <div class="language-dos extra-class"><pre class="language-text"><code>set DEBUG=* &amp; netlify deploy </code></pre></div><p>In Windows PowerShell, use <code>$env:</code> to set the variable:</p> <div class="language-powershell extra-class"><pre class="language-powershell"><code><span class="token variable">$env</span>:DEBUG=<span class="token string">'*'</span><span class="token punctuation">;</span>netlify deploy </code></pre></div><div id="getting-help" class="legacy-anchor"></div> <h2 id="get-help"><a href="#get-help" class="header-anchor">#</a> Get help</h2> <p>To get usage tips and learn more about available commands from within Netlify CLI, run the following:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify <span class="token builtin class-name">help</span> </code></pre></div><p>For more information about a specific command, run <code>help</code> with the name of the command.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify <span class="token builtin class-name">help</span> deploy </code></pre></div><p>This also works for sub-commands.</p> <div class="language-bash extra-class"><pre class="language-bash"><code>netlify <span class="token builtin class-name">help</span> sites:create </code></pre></div><p>If you have additional questions or ideas for new features, you can <a href="https://github.com/netlify/cli/issues" target="_blank" rel="noopener noreferrer">start an issue</a> on Netlify CLI’s open source repository. You can also visit our <a href="https://answers.netlify.com/categories" target="_blank" rel="noopener noreferrer">Support Forums</a> to start or join a conversation. We’d love to hear from you!</p></div> <div><p id="get-started-with-netlify-dev" class="legacy-redirect"><a href="/cli/local-development/#get-started-with-netlify-dev">Local development with Netlify Dev: Get started with Netlify Dev</a></p><p id="share-a-live-development-server" class="legacy-redirect"><a href="/cli/local-development/#share-a-live-development-server">Local development with Netlify Dev: Share a live development server</a></p><p id="configuration-and-more-resources" class="legacy-redirect"><a href="/cli/local-development/#configuration">Local development with Netlify Dev: Configuration</a></p></div> <div class="content__default wrapper__last_updated has_page_nav"><time datetime="2024-10-02"> Last updated: October 2, 2024 </time></div> <div class="footer-page-nav"><p class="inner"><!----> <span class="next"><a href="/cli/local-development/"> Local development with Netlify CLI </a> → </span></p></div> <div class="feedback"><div class="media"><div class="media__body"><h4 class="media__title"> Did you find this doc useful? </h4> <!----> <p class="media__copy"> Your feedback helps us improve our docs. </p> <!----> <!----></div> <div class="media__figure"><button aria-label="upvote" class="feedback__vote feedback__vote--upvote"><svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" aria-hidden="true"><g fill="none" fill-rule="evenodd"><circle cx="32" cy="32" r="32" fill="none" fill-rule="nonzero"></circle> <g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M40 29h-7.645l1.473-3.889c.377-.996.042-2.135-.803-2.73-.963-.679-2.263-.427-2.936.569L26 29v9a4 4 0 0 0 4 4h6.517c1.51 0 2.893-.852 3.573-2.203L42 36v-5a2 2 0 0 0-2-2zM22 29v12"></path></g></g></svg></button><button aria-label="downvote" class="feedback__vote feedback__vote--downvote"><svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" aria-hidden="true"><g fill="none" fill-rule="evenodd"><circle cx="32" cy="32" r="32" fill="none" fill-rule="nonzero"></circle> <g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M23 35h7.645l-1.473 3.889c-.377.996-.042 2.135.803 2.73.963.679 2.263.427 2.936-.569l4.09-6.05v-9a4 4 0 0 0-4-4h-6.518c-1.51 0-2.893.852-3.573 2.202L21 28v5a2 2 0 0 0 2 2zM41 35V23"></path></g></g></svg></button></div></div> <div><form class='form form--floating-labels feedback__form--appear' method='post' name='feedback'><input type="hidden" name="form-name" value="feedback"> <input type="hidden" name="path" value="/cli/get-started/"> <input type="hidden" name="vote" value=""> <label class="visuallyhidden"> Do not fill in this field <input name="verification" value=""></label> <div class="form__field"><label><div class="form__label"> What else would you like to tell us about this doc? </div> <textarea name="feedback" class="form__textarea"></textarea></label></div> <div class="btn-group"><button disabled="disabled" class="btn"> Send </button></div></form></div></div> <footer class="footer"><div class="footer-wrapper"><nav aria-label="Footer navigation" class="footer-nav"><ul class="footer__nav"><li class="footer__nav-item"><a href="https://netlify.com/" class="footer__nav-link"> Netlify </a></li> <li class="footer__nav-item"><a href="https://netlify.com/careers/" class="footer__nav-link"> Careers </a></li> <li class="footer__nav-item"><a href="https://netlify.com/blog/" class="footer__nav-link"> Blog </a></li> <li class="footer__nav-item"><a href="https://www.netlify.com/legal/terms-of-use/" class="footer__nav-link"> Terms </a></li> <li class="footer__nav-item"><a href="https://www.netlify.com/privacy/" class="footer__nav-link"> Privacy </a></li></ul></nav> <div class="dark-mode-widget footer__theme-toggle" data-v-0d17f8d5><label for="theme-select" class="visuallyhidden" data-v-0d17f8d5>Select a theme</label> <div class="forms-select-c" data-v-0d17f8d5><div class="theme-toggle-icon" data-v-0d17f8d5><svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-0d17f8d5><path fill-rule="evenodd" clip-rule="evenodd" d="M14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7ZM7 12.2C6.99999 12.2 7.00001 12.2 7 12.2C4.12812 12.2 1.8 9.87188 1.8 7C1.8 4.12812 4.12812 1.8 7 1.8C7.00001 1.8 6.99999 1.8 7 1.8V12.2Z" fill="currentColor"></path></svg> <!----> <!----></div> <select value="system" name="theme-select" id="theme-select" class="forms-input"> <option value="system" data-v-0d17f8d5>System</option><option value="light" data-v-0d17f8d5>Light</option><option value="dark" data-v-0d17f8d5>Dark</option></select> <svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down forms-select-c-arrow"><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg></div></div></div> <p class="footer__copyright">© 2025 Netlify</p></footer></section></main></div><div class="global-ui"></div></div> <script src="/assets/js/app.4a12bea4.js" defer></script><script src="/assets/js/6.f7eff80e.js" defer></script><script src="/assets/js/2.1c921067.js" defer></script><script src="/assets/js/91.272c9eb8.js" defer></script><script src="/assets/js/16.bc1aa620.js" defer></script><script src="/assets/js/32.07d46218.js" defer></script><script src="/assets/js/31.2c355c7b.js" defer></script> <script src="/netlify-cnm/cnm.js" async defer></script> <script async id="netlify-rum-container" src="/.netlify/scripts/rum" data-netlify-rum-site-id="90a54386-9477-4113-bd6a-b9227b573d00" data-netlify-deploy-branch="main" data-netlify-deploy-context="production" data-netlify-cwv-token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaXRlX2lkIjoiOTBhNTQzODYtOTQ3Ny00MTEzLWJkNmEtYjkyMjdiNTczZDAwIiwiYWNjb3VudF9pZCI6IjU4ZGE4ODkzZDY4NjVkMzVjOTJhNzJiOCIsImRlcGxveV9pZCI6IjY3YWY5MjQyM2MyMzIwMDAwOGVkNWViYiIsImlzc3VlciI6Im5mc2VydmVyIn0.ITO2hYKD-bfMx7Aojk4qxSrtteyJXD3ljjojUDrlsYA"></script><script type="text/javascript"> if (window.location.host === "docs.netlify.com") { !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.13.1"; analytics.load("kjz0qkJslzzHMcNGI3GkDb9HDZ6vspYZ"); }}(); } </script></body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10