{"id":771,"date":"2016-07-30T14:19:19","date_gmt":"2016-07-30T08:49:19","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=771"},"modified":"2026-09-06T16:08:58","modified_gmt":"2026-09-06T10:38:58","slug":"installing-nodenpm-and-pm2","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/installing-nodenpm-and-pm2\/","title":{"rendered":"Installing node,npm and pm2"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide covers how to <strong>install Node.js, npm, and PM2<\/strong> on a Linux server \u2014 the standard toolchain for running JavaScript applications outside the browser, plus a process manager to keep them running reliably.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Node.js<\/strong> runs JavaScript on the server. <strong>npm<\/strong> (Node Package Manager) comes bundled with it and installs JavaScript packages. <strong>PM2<\/strong> is a process manager that keeps your Node application running in the background, automatically restarts it if it crashes, and can bring it back up after a server reboot.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">I. Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before you install Node.js, npm, and PM2, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Linux server with root or sudo access<\/li>\n\n\n\n<li><code>wget<\/code> and <code>tar<\/code> available (installed by default on most distributions)<\/li>\n\n\n\n<li>Your application&#8217;s code ready to deploy, if you plan to run it immediately after setup<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">II. Download and Extract Node.js<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/opt\nwget https:\/\/nodejs.org\/dist\/v20.17.0\/node-v20.17.0-linux-x64.tar.gz\ntar -xvf node-v20.17.0-linux-x64.tar.gz\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Always check the <a href=\"https:\/\/nodejs.org\/en\/download\" target=\"_blank\" rel=\"noopener\">official Node.js downloads page<\/a> for the current LTS version rather than reusing an old, hardcoded version number \u2014 Node.js releases regular security updates, and versions from several years back (like v6.x) have long since reached end-of-life and no longer receive patches.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">III. Create Symlinks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Link the extracted binaries into <code>\/usr\/bin<\/code> so <code>node<\/code> and <code>npm<\/code> are available system-wide:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ln -sf \/opt\/node-v20.17.0-linux-x64\/bin\/node \/usr\/bin\/node\nln -sf \/opt\/node-v20.17.0-linux-x64\/bin\/npm \/usr\/bin\/npm\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Double-check the path is <code>\/usr\/bin<\/code>, not <code>\/use\/bin<\/code> \u2014 a one-character typo here is an easy mistake to carry over from a quick copy-paste, and it silently creates the symlink in a directory that doesn&#8217;t exist rather than throwing an obvious error.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">IV. Verify the Installation<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">node -v\nnpm -v\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both should print version numbers matching what you downloaded, confirming the symlinks resolved correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">V. Install PM2 Globally<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">npm install -g pm2\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">VI. Start Your Application with PM2<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pm2 start app.js --name my-app\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>app.js<\/code> with your application&#8217;s entry file. The <code>--name<\/code> flag gives the process a readable label in PM2&#8217;s process list.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">VII. Ensure PM2 Survives a Server Reboot<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This step is easy to miss, and without it, your application won&#8217;t automatically come back up if the server restarts:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pm2 startup\npm2 save\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pm2 startup<\/code> generates and configures a system service so PM2 itself starts on boot; <code>pm2 save<\/code> saves your current list of running processes so they&#8217;re restored automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">VIII. Useful PM2 Commands<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pm2 list          # Show all running processes\npm2 logs my-app   # View logs for a specific app\npm2 restart my-app\npm2 stop my-app\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">IX. Conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Installing Node.js, npm, and PM2 comes down to downloading a current LTS release, linking the binaries system-wide, and letting PM2 handle keeping your application running \u2014 including automatically restarting it after crashes or a server reboot. With <code>pm2 startup<\/code> and <code>pm2 save<\/code> configured, your Node application stays running reliably without needing manual intervention every time the server restarts.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Should I use this manual method or a version manager like nvm?<\/strong> For a single application on a dedicated server, this manual approach works fine. If you need to switch between multiple Node.js versions (for different projects or testing compatibility), <a href=\"https:\/\/github.com\/nvm-sh\/nvm\" target=\"_blank\" rel=\"noopener\">nvm<\/a> is generally more convenient, since it manages multiple installed versions without manual symlinking.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why use PM2 instead of just running <code>node app.js<\/code> directly?<\/strong> Running Node directly stops the moment you close your terminal session or the process crashes. PM2 keeps it running in the background, restarts it automatically on a crash, and can bring it back up after a reboot \u2014 none of which a plain <code>node app.js<\/code> command provides on its own.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do I need to update Node.js periodically?<\/strong> Yes \u2014 like any server software, Node.js receives security patches, and older versions eventually reach end-of-life with no further updates. Check the <a href=\"https:\/\/nodejs.org\/en\/about\/previous-releases\" target=\"_blank\" rel=\"noopener\">Node.js release schedule<\/a> periodically and plan upgrades accordingly.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Deploying and managing Node.js applications in production? Our team can help with server setup, process management, deployment pipelines, and ongoing infrastructure support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-liquibase-ubuntu\/\">Install Liquibase on Ubuntu<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/jenkins-user-creation-and-permission-management-guide\/\">Jenkins User Creation and Permission Management Guide<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction This guide covers how to install Node.js, npm, and PM2 on a Linux server \u2014 the standard toolchain for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-771","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-cr","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=771"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/771\/revisions"}],"predecessor-version":[{"id":11424,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/771\/revisions\/11424"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}