Install or update the Snyk CLI
After you install the Snyk CLI, you must authenticate. Then you can get started testing and fixing your vulnerabilities, beginning with testing your installation.
Note: Snyk recommends always keeping your CLI installation updated to the latest version. You can check which version of the Snyk CLI you have installed by running
snyk --version
.Use GitHub Releases to download a standalone executable (macOS, Linux, Windows) of Snyk CLI for your platform.
Snyk also provides these standalone executables on the Snyk Content Delivery Network (CDN). See the latest
release.json
file for the download links. Examples for a specific version or platform follow:For example, to download and run the latest Snyk CLI on macOS, you could run:
curl --compressed https://static.snyk.io/cli/latest/snyk-macos -o snyk
chmod +x ./snyk
mv ./snyk /usr/local/bin/
You can also use these direct links to download the executables:
- Windows: https://static.snyk.io/cli/latest/snyk-win.exe You can rename the file to snyk.exe so you can run snyk commands as documented, for example,
snyk test
.
To use the CLI on an Apple M1 or M2 machine, (darwin/arm64), see Prerequisite for CLI on an Apple M1 machine.
To use the CLI with Alpine Linux, see Prerequisites for CLI and Jenkins plugin on Alpine Linux operating system.
The drawback of this method is that you must keep the Snyk CLI up to date manually.
Install Snyk CLI from Snyk's tap with Homebrew by running the following. The tap is updated daily with the latest Snyk CLI release.
brew tap snyk/tap
brew install snyk
Install Snyk CLI from Snyk's bucket with Scoop by running the following. The bucket is updated daily with the latest Snyk CLI release.
scoop bucket add snyk https://github.com/snyk/scoop-snyk
scoop install snyk
Before installing the Snyk CLI using npm, be sure you have installed the prerequisites:
- Install the latest version of npm in your local environment, using Node version 12 or later. For information on how to update Node see Install or upgrade to version of Node required for Snyk CLI.
- To run Snyk on Alpine Linux, first install libstdc++. For more information see Prerequisites for CLI and Jenkins plugin on Alpine Linux operating system.
Then follow these steps to install with npm or Yarn:
Snyk CLI is available as an npm package. If you have Node.js installed locally, you can install the npm package by running
npm install snyk -g
.If you are using Yarn, install by running
yarn global add snyk
.Snyk CLI can also be run from a Docker image. Snyk offers multiple Docker images under snyk/snyk on Docker Hub. See snyk/snyk-images on GitHub for details.
These images wrap the Snyk CLI and depending on the Tag come with relevant tooling for different projects. An example follows for scanning a Gradle project with
snyk/snyk
:docker run -it \
-e "SNYK_TOKEN=<TOKEN>" \
-v "<PROJECT_DIRECTORY>:/project" \
-v "/home/user/.gradle:/home/node/.gradle" \
snyk/snyk:gradle:6.4 test --org=my-org-name
This is an example for scanning a Maven project with
snyk/snyk
:docker run --rm -r \
-e SNYK_TOKEN=<YOUR_SNYK_TOKEN> \
-v <PROJECT_DIRECTORY>:/app \
-v <PROJECT_DIRECTORY>/settings.xml:/root/.m2/settings.xml \
snyk/snyk:maven snyk monitor \
--all-projects=true \
--maven-aggregate-project
Snyk also offers many integrations into developer tooling. These integrations install and manage the Snyk CLI for you. Integrations include the following:
Last modified 10d ago