Specify a Specific Version of Node.js Environment for a Service
In ServBay, specifying a specific version of Node.js environment for a Node.js script or website is very simple. This article will explain in detail how to specify a specific Node.js version for scripts and websites.
Specify a Specific Version of Node.js for Scripts
In ServBay, you can easily specify the Node.js version for a script through the command line. Just use the node-<version>
command. For example, to run a script using Node.js 14, you can execute the following commands:
$ node-14 script.js
Hello World
Node.js Version: 14.17.0
$ node-16 script.js
Hello World
Node.js Version: 16.3.0
2
3
4
5
6
7
Example Explanation
node-14 script.js
: Runs thescript.js
script using Node.js version 14.node-16 script.js
: Runs thescript.js
script using Node.js version 16.
This way, you can flexibly test and run different versions of Node.js for compatibility.
Specify a Specific Version of Node.js for Websites
WARNING
This feature will be supported in a future version of ServBay
If you need to specify a Node.js runtime version for an entire website, it can be set through the ServBay management interface.
Steps
Open the ServBay Management Interface: Open the ServBay management interface and log in to the admin console.
Navigate to Host Settings: Click on
Host
in the navigation menu.Select the Specific Website: Find the specific website you need to configure in the website list and click the settings dropdown menu on the right.
Select Node.js Version: In the settings dropdown menu, select the Node.js version you need to use. Ensure that the corresponding Node.js service is installed and running.
Notes
- Ensure Node.js Version is Installed: Before selecting the Node.js version, make sure that the version is already installed and running in ServBay.
- Compatibility Check: After switching the Node.js version, it is recommended to check the website's compatibility to ensure all functionalities are running correctly.
Summary
In ServBay, specifying a specific version of Node.js environment is very simple. You can specify the version directly for scripts through the command line, or specify the version for an entire website through the ServBay management interface. Whether it's an individual script or a whole website, you can flexibly switch Node.js versions to meet different development and running needs.