How to Install Netlify CLI
Quick Answer
npm install netlify-cli -g (requires Node.js 18.14.0+). Verify installation with netlify --version, then authenticate with netlify login to grant CLI access to your Netlify account.Prerequisites
- Node.js version 18.14.0 or later
- npm 8 or higher
- Stable internet connection
- Terminal or command line access
- Netlify account
Verify Node.js Installation
Before installing Netlify CLI, confirm you have Node.js version 18.14.0 or later installed on your system. Run node --version in your terminal to check your current version. If you need to install or upgrade Node.js, visit the official Node.js website or use a version manager like nvm.
Install Netlify CLI Globally
Run the following command from any directory in your terminal to install Netlify CLI globally:
npm install netlify-cli -gThis makes the netlify command available from any directory on your system. The installation may take a few minutes as npm downloads and installs all required dependencies.
brew install netlify-cli.Verify the Installation
Confirm that Netlify CLI installed successfully by running:
netlify --versionThis command displays the installed CLI version and basic information about the tool. If you see a version number, the installation was successful.
netlify help to view all available commands.Authenticate with Netlify
Log in to your Netlify account from the command line by running:
netlify loginThis command opens a browser window where you can log in with your Netlify credentials and grant access to Netlify CLI. Complete the authentication process in your browser, and the CLI will automatically store your access token locally.
Locate Your Configuration File
After authentication, Netlify CLI stores your access token in a config.json global configuration file. The location depends on your operating system:
macOS: Library/Preferences/netlify/config.json
Linux: .config/netlify/config.json
Windows: AppData\Roaming\netlify\Config\config.json
The CLI uses this token automatically for all future commands, so you won't need to log in again.
Link Your Project (Optional)
If you have an existing local project, navigate to your project directory and run:
netlify linkThis command connects your local project to a Netlify site and adds a siteId field to a new .netlify/state.json file in your project folder. This step is optional but recommended for easier deployments.
netlify clone to clone a Netlify site repository and automatically link it in one step.Install for CI Environments (Optional)
If you're using Netlify CLI in a continuous integration environment like GitHub Actions or CircleCI, install it as a local development dependency instead of globally:
npm install --save-dev netlify-cliThis approach binds a specific CLI version to your project and ensures reproducible builds across different machines. Always use a lock file (package-lock.json or yarn.lock) with this method.
Test Your Installation
Run a test command to ensure everything is working correctly:
netlify statusThis command displays information about your linked Netlify site and confirms that your authentication token is valid. If you see site details, your installation and authentication are complete.
Troubleshooting
ERR_MODULE_NOT_FOUND error during installation on Node 20.x
npm install -g netlify-cli@latest. Clear your npm cache with npm cache clean --force and reinstall. This issue was fixed in v19.1.3.Sharp dependency build failures or timeout errors on Linux
sudo apt install build-essential python3 on Ubuntu/Debian. Ensure you have at least 500MB free disk space and 4GB+ RAM. Update Node.js and npm to their latest versions.Out-of-memory (OOM) kills during installation
npm install netlify-cli -g --no-optional to skip optional dependencies, or use nvm to switch to a different Node.js version.netlify command not found after installation
npm list -g netlify-cli. Check that npm's global prefix is in your system PATH. On macOS/Linux, run echo $PATH and ensure it includes your npm global directory. Restart your terminal after installation.Authentication fails or token not stored
npm cache clean --force and running netlify login again. Check that the config.json file location exists and is writable.Ready to get started with Netlify?
Put this tutorial into practice. Visit Netlify and follow the steps above.
Visit Netlify →