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

Install Serverless Devs

Select an installation method as required.
  • Use a package manager
    1. Select a package manager as required and use it to install Serverless Devs.
      • Use npm: This method applies to Windows, macOS, and Linux operating systems where npm is installed.
        Run the following command to install Serverless Devs:
        npm install @serverless-devs/s -g
        Note You must use Node.js 10.X or later. After Node.js is installed, 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 where Yarn is installed.
        Run the following command to install Serverless Devs:
        yarn global add @serverless-devs/s
    2. Run the following command to check whether Serverless Devs is installed:
      s -v
      The following code is returned if the installation is successful:
      @serverless-devs/s: 2.0.83, linux-x64, node-v14.17.4
  • Use the installation script (applicable to macOS and Linux)
    1. Run the following command to install Serverless Devs:
      curl -o- -L http://cli.so/install.sh | bash
    2. Run the following command to check whether Serverless Devs is installed:
      s -v
      The following code is returned if the installation is successful:
      @serverless-devs/s: 2.0.83, linux-x64, node-v14.17.4

Install Docker (Optional)

You may want to use the FC component of Serverless Devs to build functions, debug functions on your on-premises machine, or configure interconnection between on-premises and cloud applications by running the s build, s local, or s proxied command. In this case, Docker is required.

You can use one of the following methods to install Docker based on the operating system that you use:

FAQ

If you experience problems similar to the following ones, you can use the following methods as required for troubleshooting:
  • How do I upgrade Serverless Devs of an earlier version?

    To upgrade Serverless Devs, run the installation command again. For more information, see the Install Serverless Devs section of this topic.

  • If the installation process takes a long period, you can run the following command to use Taobao npm to install Serverless Devs:
    npm --registry=https://registry.npm.taobao.org 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 upgraded at the earliest opportunity, you can use one of the following methods as required for troubleshooting:
    • Run the following command to set the PATH environment variable:
      export PATH=$HOME/.s/node-v14.17.4-darwin-x64/bin:$PATH
    • Open a new terminal.
  • You can use one of the following methods as required for troubleshooting if the Error: EACCES: permission denied error message is returned when you install Serverless Devs in Linux or macOS:
    • If you use a package manager to install Serverless Devs, run the following command:
      sudo npm install @serverless-devs/s -g
    • If you use the installation script to install Serverless Devs, run the following command:
      sudo curl -o- -L http://cli.so/install.sh | sudo bash
  • 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/s/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/s /usr/local/bin/