How to install Netlify CLI on Netlify
Install Netlify CLI globally with <code>npm install netlify-cli -g</code> (requires Node.js 18.14.0+). Verify installation with <code>netlify --version</code>, then authenticate with <code>netlify login</code> 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
Step-by-Step Instructions
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.
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.
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.
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.
Common Issues & Troubleshooting
ERR_MODULE_NOT_FOUND error during installation on Node 20.x
Update Netlify CLI to version 19.1.3 or later with <code>npm install -g netlify-cli@latest</code>. Clear your npm cache with <code>npm cache clean --force</code> and reinstall. This issue was fixed in v19.1.3.
Sharp dependency build failures or timeout errors on Linux
Install required build tools with <code>sudo apt install build-essential python3</code> 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
Increase available RAM or free up disk space (target 500MB+ free). Try installing with <code>npm install netlify-cli -g --no-optional</code> to skip optional dependencies, or use nvm to switch to a different Node.js version.
netlify command not found after installation
Verify installation with <code>npm list -g netlify-cli</code>. Check that npm's global prefix is in your system PATH. On macOS/Linux, run <code>echo $PATH</code> and ensure it includes your npm global directory. Restart your terminal after installation.
Authentication fails or token not stored
Ensure your internet connection is stable and you have write permissions to your home directory. Try clearing npm cache with <code>npm cache clean --force</code> and running <code>netlify login</code> again. Check that the config.json file location exists and is writable.