githubEdit

Install the Snyk CLI

The Snyk CLI can be installed across all major operating systems using several different methods, depending on your existing toolset:

  • Package managers: Use tools like npm, Homebrew, or Scoop for a quick installation.

  • Docker: Run Snyk in a container for a consistent scanning environment.

  • GitHub Actions and CI/CD: Use pre-built integrations to automate scanning within your deployment pipelines.

  • Direct binary download: Download a standalone executable for Windows, MacOS, or Linux.

After you install the CLI, authenticate your Snyk account to start scanning your Snyk Projects. For more information, visit Authenticate to use the CLI.

circle-exclamation

Common installation steps

Regardless of your choice of tool, there are common steps to ensuring your installation of the Snyk CLI is a success:

  1. Install the Snyk CLI using your preferred method.

  2. Verify the installed Snyk CLI version using snyk --version.

  3. Authenticate the Snyk CLI to your account.

To learn how to upgrade the Snyk CLI for your chosen tool, visit Upgrade the Snyk CLI.

circle-info

To use CLI releases before version 1.1230.0 on an Apple M1 or M2 machine (darwin/arm64), visit Using CLI releases before version 1.1230.0 on an Apple M1 or M2 machine.

Installation methods

Package managers

chevron-rightInstall with Homebrew (MacOS and Linux)hashtag
circle-info
  1. Install and verify Homebrew using any method specified in their documentation. Visit Install Homebrewarrow-up-right for more information.

  2. Install Homebrew Tap for Snykarrow-up-right. The tap is updated daily with the latest Snyk CLI release.

  3. Install the Snyk CLI for Homebrew:

  4. Verify that the installation has succeeded:

  5. Authenticate. For more details, visit Authenticate locally.

chevron-rightInstall with npmhashtag
circle-info

Ensure you have permission to install global npm packages and network access to the npm registry to have a successful installation.

  1. For Snyk CLI version 1.853.0 or later, install the latest version of npm on your machine using Node.js version 12 or later and npm version 7 or later.

  2. Install the npm package:

  3. Authenticate. For more details, visit Authenticate locally.

chevron-rightInstall with Yarnhashtag
  1. Install with Yarn by running the command:

  2. Authenticate. For more details, visit Authenticate locally.

chevron-rightInstall with Scoop (Windows)hashtag
  1. Add the official Snyk bucket to your machine:

  2. Install the Snyk CLI:

  3. Verify that the installation has succeeded:

  4. Authenticate. For more details, visit Authenticate locally.

Docker

circle-info

Snyk offers multiple Docker images under snyk/snyk on Docker Hubarrow-up-right. To learn more, visit snyk/snyk-images on GitHubarrow-up-right.

Snyk provides a universal image and specialized images for specific package managers:

  • Universal: snyk/snyk

  • Language specific: snyk/snyk:node, snyk/snyk:maven, snyk/snyk:python, and so on.

Download the pre-packaged tools using the following command, specifying the universal or language specific image of your choosing:

Authenticate the connection. For more details, visit Authentication in Docker.

GitHub actions and CI/CD

chevron-rightGitHub actionshashtag
  1. In your Snyk account, navigate to Account Settings and copy your Auth token. Use a Service Account Token if you are an Enterprise plan user, to protect your pipeline from breaking if you as an individual leave the comapny.

  2. Navigate to Settings > Secrets and variables > Actions, and create a New repository secret in the format:

    1. Name: SNYK_TOKEN

    2. Secret: Your Snyk Auth token or Service Account Token

  3. In GitHub repository:

    1. Create a folder named .github.

    2. Within that folder, create another folder named workflows.

    3. Create a file named snyk-scan.yml. The entire filepath should be .github/workflows/snyk.yml.

    4. Add your YAML code to this file and commit it:

chevron-rightCI/CDhashtag

For detailed instructions on using the Snyk CLI with CI/CD integrations, visit Snyk CI/CDs.

Direct binary download

circle-exclamation

Snyk provides standalone executables on the Snyk Content Delivery Network (CDN). For the latest download links, visit the latest release.json filearrow-up-right.

For instructions on how to verify the shasum of downloaded binaries and their GPG signatures, visit Verifying CLI standalone binaries.

chevron-rightInstall for MacOS and Linuxhashtag

Use curl to download the binary, make it executable, and move it to your system path in one go.

For Intel/AMD (x86_64) use the following commands:

For Apple Silicon (M1/M2/M3) use the following commands:

chevron-rightInstall for Alpinehashtag

Use curl to download the binary, make it executable, and move it to your system path in one go.

For Intel/AMD (x86_64) use the following commands:

For ARM64 use the following commands:

chevron-rightInstall for Windowshashtag

For Windows, download the .exe and manually add its location to your system variables.

  1. Rename the file from snyk-win.exe to just snyk.exe.

  2. Move it to a permanent folder (for example, C:\tools\snyk\).

  3. Add to PATH:

    1. Search for Environment Variables in your Start Menu.

    2. Under System Variables, find Path and click Edit.

    3. Add the path to the folder where you saved the .exe (e.g., C:\tools\snyk\).

Last updated

Was this helpful?