Node Version Manager (NVM) is essential for managing multiple Node.js versions. In aaPanel, you can use NVM using two primary methods: the Node.js Manager plugin (via the App Store) and the Website section to manage projects directly. This guide will walk you through each technique step-by-step to help you manage Node.js environments on your server.
What is Node.js Manager and NVM in aaPanel?
Node.js Manager in aaPanel integrates the powerful features of Node Version Manager (NVM) into an intuitive, user-friendly interface. NVM enables developers to:
- Install multiple versions of Node.js.
- Switch between versions seamlessly.
- Assign specific Node.js versions to projects.
You can leverage NVM’s capabilities alongside aaPanel’s Website section and monitoring tools for an efficient Node.js development workflow.
Benefits of Using Node.js Manager and NVM in aaPanel
- Simplified Management: The Node.js Manager plugin simplifies installing, switching, and removing Node.js versions without complex terminal commands.
- Project-Specific Versions: Assign different Node.js versions to individual projects, ensuring compatibility across many applications.
- Monitoring and Debugging: Use aaPanel’s built-in tools to monitor CPU, memory usage, and logs for Node.js projects.
- Improved Flexibility: Manage PHP and Node.js projects simultaneously within the same server environment.
Method 1: Installing and Managing Node.js via the App Store
The first method involves installing and managing NVM and Node.js through the Node.js Manager plugin, available in the aaPanel App Store. This plugin is perfect for managing Node.js versions across multiple projects.
Installing Node.js Manager Plugin
- Log in to aaPanel:
- Open your browser and log in to your aaPanel dashboard.
- Access the App Store:
- From the left-hand menu, click on App Store.
- Search for Node.js Manager:
- Use the search bar to locate the Node.js Manager plugin.
- Install the Plugin:
- Click Install and wait for the process to complete.
- Once installed, the plugin will be accessible under the Website section in the Node.js Manager tab.
Installing Node.js Versions
- Access Node.js Manager:
- Navigate to Website > Node Project and click Node Version Manager.
- Install a New Version:
- You will see a list of available Node.js versions in the pop-up window.
- Choose a version to install by clicking Install next to it.
- Stable vs. Testing Versions:
- LTS (Long-Term Support) versions are marked as stable and recommended for production use.
- Testing versions can be used for development and testing purposes.
- Monitor Installation Progress:
- Awaiting installation. The installed version will now appear under the “Environment” section.
Switching Node.js Versions
- Set Command-Line Version:
- Open Node Version Manager and locate the Command Line Version dropdown.
- Select the Node.js version you want to use.
- Save Changes:
- Click Save to set the selected active version for terminal commands.
Uninstalling Node.js Versions
- Open Node Version Manager:
- In the Node Version Manager, locate the version you want to remove.
- Click Uninstall:
- Click Uninstall next to the version to remove it from your server.
- Verify Removal:
- Ensure the uninstalled version is no longer listed in the Node.js Manager interface.
Method 2: Managing Node.js Projects via the Website Section
The second method involves managing Node.js projects directly in the Website section of aaPanel. It is particularly useful for configuring individual projects.
Adding a Node.js Project
- Navigate to the Website Section:
- Go to Website in the aaPanel dashboard.
- Switch to Node Project Tab:
- Click on the Node Project tab.
- Add Node.js Project:
- Click the Add Node Project button.
- A configuration window will pop up for project details.
Configuring Node.js Settings
- Enter Project Information:
- Project Name: Enter a name for the project.
- Document Root: Specify the directory where your project files are stored.
- Node.js Version: Select the appropriate Node.js version for the project from the dropdown.
- Save the Project:
- Click Confirm to add the project to the list.
Starting and Monitoring Node.js Projects
- Start the Project:
- In the Node Project tab, locate the project and click Start.
- Monitor Status:
- Check the project’s Status, PID, CPU, and RAM usage.
- Use the logs to monitor real-time output or debug errors.
- Enable SSL (Optional):
- For secure connections, configure SSL in the project settings.
Best Practices for Using NVM in aaPanel
- Regular Updates:
- Keep the Node.js Manager version list updated to access the latest releases.
- Use LTS Versions for Production:
- Always use Long-Term Support (LTS) versions for stable and secure applications.
- Isolate Project Versions:
- Assign specific Node.js versions to projects to avoid compatibility issues.
- Monitor Resource Usage:
- Regularly monitor CPU and RAM usage for Node.js projects using Panel built-in tools.
Troubleshooting Common Issues
Issue 1: Node.js Version Not Available
Solution:
Update the version list by clicking Update Version List in the Node Version Manager pop-up.
Issue 2: Node.js Project Not Starting
Solution:
Check for missing dependencies with:
npm install
Make sure the project’s Node.js version is correctly configured.
Issue 3: High CPU or RAM Usage
- Solution:
- Optimise application code and dependencies.
- Upgrade your server resources if necessary.
Conclusion
Using Node Version Manager (NVM) in Panel is a powerful way to manage Node.js environments. With the Node.js Manager plugin and the Website section, you can easily:
- Install, switch, and manage Node.js versions.
- Configure and run multiple Node.js projects with specific settings.
Following this guide, you can set up and maintain Node.js applications on your aaPanel server. For additional support, refer to aaPanel’s official documentation or community forums.
About the writer
Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.