This article describes steps to install and use the Sails.js framework on Ubuntu Linux.
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 modern app requirements that include salable data-driven APIs and more.
It supports databases such as MySQL, PostgreSQL, MongoDB, and Redis.
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 must 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.
curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh -o install_nvm.sh | bash install_nvm.sh
Next, run the commands below to register the nvm command with your bash profile.
source ~/.bashrc
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.
nvm install --lts
Install Sails.js
At this point, NVM and Node.js are both installed. Next, run the commands below to install Sails globally.
npm -g install sails
Once installed, version Sails version number using the commands below.
sails --version
Create Sails app
Once Sails is installed, run the commands below to create your first geek-app app.
sails new 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.
cd geek-app npm install sails lift
Open your browser and browse to the server hostname or IP address, followed by port number 1337, to see the Sails web portal.
http://localhost:1337

Create Sails systemd service
To quickly start and stop Sails services, create a systemd file. Run the commands below to create the file.
sudo sudo nano /etc/systemd/system/geek-app.service
Copy and paste the lines below into the file and save.
[Unit] After=network.target [Service] Type=simple User=richard WorkingDirectory=/home/richard/geek-app ExecStart=/home/richard/.nvm/versions/node/v16.17.1/bin/node app.js Restart=on-failure [Install] WantedBy=multi-user.target
Replace the User, WorkingDirectory, and ExecStart variables values with your username, application path, and the path to your node application.
Also, ensure the node’s path is correct in your home directory.
Reload the systemd daemon service and start Sails.
sudo systemctl daemon-reload sudo systemctl enable geek-app --now
Now you should be able to stop and start Sails using the commands below.
sudo systemctl stop geek-app sudo systemctl start geek-app
When you check the status, you should see something similar as below:
● geek-app.service
Loaded: loaded (/etc/systemd/system/geek-app.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-10-10 14:22:01 CDT; 8s ago
Main PID: 22377 (node)
Tasks: 22 (limit: 4626)
Memory: 167.1M
CPU: 3.127s
CGroup: /system.slice/geek-app.service
├─22377 /home/richard/.nvm/versions/node/v16.17.1/bin/node app.js
└─22385 grunt "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ">
Oct 10 14:22:03 Ubuntu2204 node[22377]: info: ____---___--___---___--___---___--___-__
Oct 10 14:22:03 Ubuntu2204 node[22377]: info:
Oct 10 14:22:03 Ubuntu2204 node[22377]: info: Server lifted in `/home/richard/geek-app`
Oct 10 14:22:03 Ubuntu2204 node[22377]: info: To shut down Sails, press <CTRL> + C at any time.
Oct 10 14:22:03 Ubuntu2204 node[22377]: info: Read more at https://sailsjs.com/support.
Oct 10 14:22:03 Ubuntu2204 node[22377]: debug: -------------------------------------------------------
Oct 10 14:22:03 Ubuntu2204 node[22377]: debug: :: Mon Oct 10 2022 14:22:03 GMT-0500 (Central Daylight Time)
Oct 10 14:22:03 Ubuntu2204 node[22377]: debug: Environment : development
Oct 10 14:22:03 Ubuntu2204 node[22377]: debug: Port : 1337
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.
You may also use the Let’s Encrypt certificate with Sails. Below are two posts that may help you.
That should do it!
Conclusion:
- Sails.js simplifies the development of enterprise-grade Node.js apps and real-time web applications on Ubuntu Linux.
- Installation includes setting up Node.js with NVM, installing Sails globally, and creating a Sails app.
- Systemd service creation and usage enable efficient start and stop of Sails and effective use of reverse proxies like Nginx and Apache.
- Let’s Encrypt certificates can seamlessly integrate with Sails for secure web traffic.
- This guide provides a comprehensive overview of installing and utilizing the Sails.js framework on Ubuntu Linux, ensuring a solid foundation for building powerful web applications.
Leave a Reply