Serverless Devs is the command-line tool for developing and deploying Function Compute applications. This page shows you how to install Serverless Devs on macOS, Linux, or Windows, verify the installation, and optionally install Docker for local debugging.
Install Serverless Devs
Prerequisites
Before you begin, make sure you have:
A supported operating system: macOS, Linux, or Windows
(Required for npm and Yarn methods) Node.js 10 or later — run
node --versionto check
Installation methods
Choose one of the following methods based on the tools available on your system.
Use npm (Windows, macOS, Linux)
Run:
sudo npm install @serverless-devs/s -gNote: Node.js 10 or later is required. Run node --version to check your current version.Use Yarn (Windows, macOS, Linux)
Run:
sudo yarn global add @serverless-devs/sUse the install script (macOS and Linux)
Run:
curl -o- -L http://cli.serverless-devs.com/install.sh | bashAfter the installation is complete, configure the environment variables as prompted. Otherwise, the installation cannot take effect in a timely manner. For more information, see the Troubleshooting section below.
Verify the installation
Run the following command to confirm that Serverless Devs is installed:
s -vExpected output:
@serverless-devs/s: 2.0.83, linux-x64, node-v14.17.4If the s command is not found, see the troubleshooting section below.
Install Docker
Docker is required only if you run s local (local debugging) or s build --use-docker (Docker-based dependency installation or project builds). If you don't use these commands, skip this section.
When Docker is required, Serverless Devs automatically creates and manages a Docker container for you.
Download Docker for your operating system:
Windows: Docker Desktop for Windows. If you experience network issues, use the Alibaba Cloud mirror for Windows.
macOS: Docker Desktop for macOS. If you experience network issues, see the Docker Desktop for Mac install page.
Linux: Follow the Docker Engine installation guide for Ubuntu. If you experience network issues, use the Alibaba Cloud Docker community edition mirror.
Troubleshooting
Slow download speed
Use the Alibaba Cloud npm mirror registry to speed up the download:
npm --registry=https://registry.npmmirror.com install @serverless-devs/s -gs -v still shows the old version after an upgrade
Run the upgrade command again (same as the original install command), then try one of the following:
Export the path to the new binary manually:
export PATH=$HOME/.s/node-v14.19.3-linux-x64/bin:$PATHNote: Replace
node-v14.19.3with the Node.js version installed on your system. The version varies by operating system.Open a new terminal window and run
s -vagain.
Command not found when running s on Linux or macOS
Create a symlink so that s is accessible from your PATH:
If you installed via npm or the install script:
ln -s $(npm root -g)/@serverless-devs/s/bin/s /usr/local/bin/sIf you installed via Yarn:
ln -s $(yarn global dir)/node_modules/@serverless-devs/s /usr/local/bin/
Upgrade Serverless Devs
Run the original installation command again. The package manager overwrites the existing version in place.