All Products
Search
Document Center

Function Compute:Install Serverless Devs and dependencies

Last Updated:Feb 18, 2024

This topic describes how to install Serverless Devs and Docker in macOS, Linux, and Windows.

Install Serverless Devs

Note

Function Compute allows you to install Serverless Devs by using CLI tools.

  1. Install Serverless Devs by using one of the following methods:

    • Use a package manager

      • Use npm. This method applies to Windows, macOS, and Linux operating systems for which npm is installed.

        Run the following command to install Serverless Devs:

        sudo npm install @serverless-devs/s -g
        Note

        If you use this method to install Serverless Devs, Node.js must be Node.js 14 or later. After the installation, you can run the node --version command to view the version of Node.js.

      • Use Yarn. This method applies to Windows, macOS, and Linux operating systems for which Yarn is installed.

        Run the following command to install Serverless Devs:

        sudo yarn global add @serverless-devs/s3
    • Use a script. This method is applicable to macOS and Linux.

      Run the following command to install Serverless Devs:

      curl -o- -L http://cli.so/install3.sh | bash

      After the installation is complete, you must configure the environment variables as prompted. Otherwise, the installation cannot take effect in a timely manner. For more information, see FAQ.

  2. Run the following commands to check whether Serverless Devs is successfully installed:

    sudo s -v

    The following sample code is returned if Serverless Devs is successfully installed.

    @serverless-devs/s: 3.0.1, s-home: /root/.s, linux-x64, node-v14.17.4

Install Docker

If you want to use the FC component of Serverless Devs to build, run and debug functions on an on-premises machine, such as running the s build and s local commands, you must install Docker in your development environment. After Docker is installed, Serverless Devs automatically creates a Docker container and performs debugging when Docker is required.

Note

If you do not run Serverless Devs s local for local debugging or run s build commands to install dependencies or build projects, you do not need to install Docker.

FAQ

  • How do I upgrade Serverless Devs of an earlier version?

    You can run the installation command again to upgrade Serverless Devs. For more information, see Install Serverless Devs.

  • If the installation process takes a long time, you can use the following npm source to install Serverless Devs. Example command:

    npm --registry=https://registry.npmmirror.com install @serverless-devs/s -g
  • If you check the version of Serverless Devs after you upgrade Serverless Devs and find that Serverless Devs is not installed, you can use one of the following methods for troubleshooting based on your business requirements:

    • Run the following command to configure environment variables:

      export PATH=$HOME/.s/node-v16.16.0-linux-x64/bin:$PATH
      Note

      The version number node-v16.16.0 in this command is only an example. Use the actual version number of your runtime.

    • Open a new terminal.

  • After Serverless Devs is installed in Linux or macOS, an error may occur when you run a command provided by Serverless Devs. You can use one of the following methods as required for troubleshooting if the Command not found error message is returned:

    • If you used npm or the installation script to install Serverless Devs, run the following command:

      ln -s $(npm root -g)/@serverless-devs/s3/bin/s /usr/local/bin/s
    • If you used Yarn to install Serverless Devs, run the following command:

      ln -s $(yarn global dir)/node_modules/@serverless-devs/s3/bin/s /usr/local/bin/