The pain of installing Serverless

I've always run into permissions/dependency issues when installing serverless on a new machine. First, it needs node installed, which I'm not the least bit familiar with. Then it needs npm which is a package manager. So far, okay.

But the serverless documentation for installing it is not super useful, IMHO, for it's not super clear about what to do if you simply can't find your serverless command or fail to install it despite following the tutorial.

Do this instead

( Thanks to this answer on SO: https://stackoverflow.com/a/66166866/5486022 )

  • Step 1: Install Node

    1. Go to https://nodejs.org/en/ and download the node installer for you system (I use Linux)

    2. $ sudo apt update

    3. $ sudo apt install xz-utils

    4. $ sudo tar -xvf name_of_file (let it be node-v14.15.5-linux-x64)

    5. $ sudo cp -r node-v14.15.5-linux-x64/{bin,include,lib,share} /usr/

    6. $ node --version

You should now have node installed on your system

  • Step 2: Install Serverless as a project dependency (avoid global install npm install -g serverless)

    ( Thanks to this answer on SO: https://stackoverflow.com/a/68069795/5486022 )

    1. $ npm i -D serverless (At your serverless project root)

    2. $ npx sls --version

    3. $ npx serverless deploy OR npx sls deploy

You should now have Serverless installed for your project