Tools: Latest: Installing Node.js and npm on Ubuntu 26.04

Tools: Latest: Installing Node.js and npm on Ubuntu 26.04

Manage Multiple Versions with NVM

Test the Installation

Next Steps Ubuntu's default APT repository ships an outdated Node.js build that is not suitable for modern JavaScript development. This guide installs Node.js 24.x from the NodeSource repository and covers NVM as an alternative for managing multiple versions side by side, verified with a running Express application confirming the setup. NodeSource maintains a Debian/Ubuntu repository that tracks current Node.js major releases, providing a single pinned version installed system-wide. 1. Update the APT package index: 2. Download the NodeSource setup script: 3. Run the setup script: 5. Verify the installation: NVM allows installing and switching between Node.js versions without affecting system-wide packages, making it suitable for environments where different projects require different runtimes. 1. Download and run the NVM installer: 2. Reload the shell environment: 3. Install the latest LTS release: 4. Install a specific version: 5. Switch to that version: 6. Set it as the default: 7. Verify the active version: A minimal Express application confirms Node.js and npm are installed and working correctly. 1. Create a project directory: 2. Initialize the project: 4. Create the application file: 5. Open port 3000 in the firewall: 6. Start the application: 7. Test in a second terminal: The response Hello World from Node.js confirms the server is running correctly. Node.js and npm are now installed and serving requests. From here you can: For the complete guide, visit the original article on Vultr Docs. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 500;">curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh $ -weight: 500;">curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh $ -weight: 500;">curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh $ -weight: 600;">sudo bash nodesource_setup.sh $ -weight: 600;">sudo bash nodesource_setup.sh $ -weight: 600;">sudo bash nodesource_setup.sh $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nodejs -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nodejs -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nodejs -y $ node -v $ -weight: 500;">npm -v $ node -v $ -weight: 500;">npm -v $ node -v $ -weight: 500;">npm -v $ -weight: 500;">curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/-weight: 500;">install.sh | bash $ -weight: 500;">curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/-weight: 500;">install.sh | bash $ -weight: 500;">curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/-weight: 500;">install.sh | bash $ source ~/.bashrc $ source ~/.bashrc $ source ~/.bashrc $ nvm -weight: 500;">install --lts $ nvm -weight: 500;">install --lts $ nvm -weight: 500;">install --lts $ nvm -weight: 500;">install 24 $ nvm -weight: 500;">install 24 $ nvm -weight: 500;">install 24 $ nvm use 24 $ nvm use 24 $ nvm use 24 $ nvm alias default 24 $ nvm alias default 24 $ nvm alias default 24 $ mkdir ~/example-app && cd ~/example-app $ mkdir ~/example-app && cd ~/example-app $ mkdir ~/example-app && cd ~/example-app $ -weight: 500;">npm init -y $ -weight: 500;">npm init -y $ -weight: 500;">npm init -y $ -weight: 500;">npm -weight: 500;">install express $ -weight: 500;">npm -weight: 500;">install express $ -weight: 500;">npm -weight: 500;">install express $ nano index.js $ nano index.js $ nano index.js const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World from Node.js') }) app.listen(port, () => { console.log(`Application listening on port ${port}`) }) const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World from Node.js') }) app.listen(port, () => { console.log(`Application listening on port ${port}`) }) const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World from Node.js') }) app.listen(port, () => { console.log(`Application listening on port ${port}`) }) $ -weight: 600;">sudo ufw allow 3000/tcp $ -weight: 600;">sudo ufw allow 3000/tcp $ -weight: 600;">sudo ufw allow 3000/tcp $ node index.js $ node index.js $ node index.js $ -weight: 500;">curl http://localhost:3000 $ -weight: 500;">curl http://localhost:3000 $ -weight: 500;">curl http://localhost:3000 - Deploy your application with PM2 for process management and automatic restarts on failure - Configure Nginx as a reverse proxy to serve the application on port 80 - Use nvm ls-remote to browse all available Node.js releases