How To Install Node.js on Debian 10 / Debian 9 Feb 16, 2020 Raj 2 min read CONTENTS Node.js Versions Prerequisites Add Node.js Repository Node.js v12.x (LTS) Node.js v13.x (Current Latest version) Install Node.js Install Yarn Create Test Web Server Verify Node.js Installation Conclusion SHARE THIS DOCUMENT IS ALSO AVAILABLE FOR CentOS 8 CentOS 7 Linux Mint 19 Ubuntu 18.04 Ubuntu 16.04 Node.js is a free and open-source, cross-platform JavaScript runtime built on Google’s V8 JavaScript engine for developing web applications and network tools, Node.js lets you use JavaScript for server-side scripting to create dynamic web page contents before the page is sent to the user’s web browser. It uses an event-driven and non-blocking I/O model, which makes Node.js fast and scalable. Ryan Dahl developed Node.js in 2009. Node.js Versions There are two versions of Node.js available for the users. v12.x (Long Term Supported) v13.x (Current Latest Version) Prerequisites Update the repository index. sudo apt update Install build tools if you plan to compile and install native addons from npm. sudo apt install -y build-essential curl Add Node.js Repository NodeSource maintains Node.js binary packages for Debian operating systems. You can configure any one of the Node.js version’s repository depending upon your requirement. Node.js v12.x (LTS) curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - Node.js v13.x (Current Latest version) curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - Install Node.js Once after adding the repository on your system, install the Node.js by using the apt command. Installing Node.js will also install the NPM (Node Package Manager). sudo apt install -y nodejs Check the version of Node.js and NPM using the following command. The following output is for your information only. nodejs -v Output: v12.15.0 NPM version. npm -v Output: 6.13.4 Install Yarn Yarn is another package manager to install and manage packages for Node.js. To install the Yarn package manager, run: curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update sudo apt install -y yarn Create Test Web Server Now, we will create a web server and run with Node.js to test the Node.js installation. Let’s create a file called web_server.js. nano web_server.js Place the below content into the web_server.js file. const http = require('http'); const port = 8080; const server = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }); server.listen(port, () => { console.log(`Node.js server listening on port ${port}`); }); Now, start the webserver with Node.js. nodejs --inspect web_server.js You should get the following message on your terminal. Debugger listening on ws://127.0.0.1:9229/c7b0e7d1-9753-4501-84b2-293065fdc650 For help, see: https://nodejs.org/en/docs/inspector Node.js server listening on port 8080 This message confirms that the webserver has been started and listening on port 8080. Verify Node.js Installation Open a browser and go to the below address. http://your.ip.add.ress:8080 You should get the Hello World page. Web Page Served by Node.js Conclusion That’s All. You have successfully installed Node.js on Debian 10 / Debian 9. debian-10 debian-9 nodejs Prev Post How To Install MongoDB On CentOS 8 / RHEL 8 Next Post How to Install Ruby on Rails on CentOS 8 / RHEL 8 Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus RECENT POSTS How To Install VirtualBox On Linux Mint 20 How To Backup and Restore Ubuntu & Linux Mint With Timeshift How To Upgrade To Linux Mint 20 From Linux Mint 19 [Detailed Guide] How To Install KVM On Ubuntu 20.04 / Linux Mint 20 How To Install Plex Media Server On Ubuntu 20.04 / Linux Mint 20 How To Install Android Studio on Ubuntu 20.04 TOP POSTS Install xrdp on CentOS 7 / RHEL 7 Install Gnome GUI on CentOS 7 / RHEL 7 Change default network name (ens33) to old “eth0” on Ubuntu… Install μTorrent (uTorrent) on Ubuntu 14.04 How To Configure High-Availability Cluster on CentOS 7 /… How To Install and Configure VNC Server in CentOS 7 / RHEL 7