Sails make it easy to build custom, enterprise-grade Node.js apps, including real-time web applications. Sails are designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern app that includes salable data-driven APIs and more. It supports databases such as MySQL, PostgreSQL, MongoDB, Redis, and many others. Below is how to install Sails.js on Ubuntu Linux.
How to install Sails.js on Ubuntu Linux
As described above, Sails makes it easy to build custom, enterprise-grade Node.js apps, including real-time web applications. Below is how to install and use it on Ubuntu Linux. To install Sails, you will need to first install Node.js using Node Version Manager (nvm).
Install NVM
Run the following command to download and install NVM. The current and latest version of NMM at the time of this post is 0.39.1. Free to switch the version number in the line below when a new version is added. Next, run the commands below to register the nvm command with your bash profile. NVM should now be installed.
Install Node.js
Now that NVM is installed, use it to download and install Node.js. To install the latest stable version of Node.js, run the commands below.
Install Sails.js
At this point, NVM and Node.js are both installed. Run the commands below to install Sails globally. Once installed, version Sails version number using the commands below.
Create Sails app
Once Sails is installed, run the commands below to create your first app called geek-app. When prompted to choose the type of app, choose Web App. Next, change into the app directory, install npm and start the app. Open your browser and browse to the server hostname or IP address followed by port number 1337 to see the Sails web portal.
Create Sails systemd service
To quickly start and stop Sails services, create a systemd file. Run the commands below to create the file. Copy and paste the lines below into the file and save. Replace the values for the User, WorkingDirectory, and ExecStart variables with your username, application path, and the path to your node application. Also, make sure the path for a node is correct in your home directory. Reload the systemd daemon service and start Sails. Now you should be able to stop and start Sails using the commands below. When you check the status, you should see something similar as below:
Using reverse proxy
The most efficient way to use Sails is to run it behind a reverse proxy. Below are two posts that show you how to set up a reverse proxy with either Nginx or Apache.
How to set up a reverse proxy with Nginx How to set up a reverse proxy with Apache
You may also use the Let’s Encrypt certificate with Sails. Below are two posts that may help you.
Set up Let’s Encrypt with Nginx Set up Let’s Encrypt with Apache
That should do it! Conclusion: This post showed you how to install and use the Sails.js framework in Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.