Skip to content

How to install Serverless locally

Serverless recommends to install itself globally. This is notably required to make commands such as “serverless” or the shortcut “sls” available in the command line.

However, projects created to Serverless 0.5 cannot be deployed using Serverless 1.x. So, with the official instructions, if you have one project in Serverless 0.5 and the other in Serverless 1.x, you’re basically screwed.

Gladly, it’s actually fairly easy to use a non-global installation of Serverless.
Basically, you just need to install Serverless locally (and while you’re at it, mark it as a development dependency):
npm install serverless@0.5.5 --save-dev
You might want to have a look in your package.json file and lock down the version completely, if that you want (I believe that by default, minor revisions are allow, ie 0.5.5 may get upgraded to 0.5.6).

Then, you need to recreate the “serverless” or “sls” command (or whatever alias you want). For this, simply create a bash file (Windows .bat, Linux/Mac .sh), in your project’s root folder, with the following content:
– on Windows:
node node_modules\serverless\bin\serverless %*
– on Linux or Mac:
node node_modules\serverless\bin\serverless $*

Finally, to run serverless dash deploy, for instance, if you named your bash file slslocal.bat, just run instead:
slslocal dash deploy

Posted in JavaScript / TypeScript / Node.js.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA