How to Install Sails.js Framework on Ubuntu Linux

Image by vectorjuice on Freepik

Node.js and JavaScript have become incredibly popular in web development. Practically, many websites and applications carry some of them. Today, you will learn about Sails.js on Ubuntu, another framework for Node.js.

Introduction

According to Sails.JS website

It is the MVC framework for Node.js

That is to say that using sails, you can have a framework with which to develop Node.js applications. The best of all is that it is inspired by MVC, which is one of the most common development patterns out there.

It is designed to resemble the MVC architecture from frameworks like Ruby on Rails, but with support for the more modern, data-oriented style of web app & API development.

Over time, Sails has gained popularity among developers for being fast and especially useful in the creation of real-time applications, so important for the web.

Another relevant aspect of Sails is that it is compatible with several database managers such as PostgreSQL, MariaDB, MongoDB or Redis. But not only that, the community has created connectors for many more. This makes it especially versatile for many projects.

Install Sails.js on Ubuntu

The main requirement to get the framework is simply to have a working Node.js installation. However, they recommend using the latest LTS version available.

So, it’s good to listen to them.

Install Node.js on Ubuntu

To get the latest LTS version available, it’s best to use the NodeSource repository to make the process easier.

So, open a terminal and update the whole system, as it is always recommended.

sudo apt update
sudo apt upgrade

Then, add the repository to get the LTS version of Node.js

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Refresh Ubuntu repositories to accept the changes

sudo apt update

Finally, you can install Node.js in its 18.x version with the following command

sudo apt install nodejs
Install Node.JS on Ubuntu
Install Node.JS on Ubuntu

You can check the installed version by running the following command

node -v

Sample output

v18.16.0

Install Sails.JS

Now that you have Node.js installed and working properly, you will need to install Sails. To achieve this, just use npm

sudo npm -g install sails
Install Sails.js on Ubuntu
Install Sails.js on Ubuntu

Then, you can check the installed version of Sails.

sails --version

Sample output:

1.5.4

All that’s left is to start using it. Create a new test application.

sails new imaginelinux-app
Creating a new Sails App
Creating a new Sails App

You will get a screen where you will have to indicate that the project is a new web application.

This will create a new folder with the name of the application you have made. Access it.

cd imaginelinux-app

And inside you will have to install the Sails dependencies.

npm install

up to date in 2s

16 packages are looking for funding
  run `npm fund` for details

If you want to start it at once to verify everything, you can execute

sails lift

This will make the app available from a web browser at the http://yourserver:1337 address.

Sails.JS running on Ubuntu
Sails.JS running on Ubuntu

So, that’s it. Now you can continue working with Sails. When you have your app ready, a good idea is to create a reverse proxy and a Systemd service to manipulate it better.

Conclusion

Sails is a modern framework for Node.js that is intended to help with the creation of complete web applications using MVC. This makes its learning curve low and accessible to many users.

I hope you liked this post, and you can share it with your friends.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top