{"id":1219,"date":"2026-12-01T13:00:00","date_gmt":"2026-12-01T13:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=1219"},"modified":"2026-12-01T13:00:00","modified_gmt":"2026-12-01T13:00:00","slug":"install-latest-nodejs-ubuntu-22-04-ppa","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/12\/01\/install-latest-nodejs-ubuntu-22-04-ppa\/","title":{"rendered":"How to Install Latest Node.js on Ubuntu 22.04 (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Install latest Node.js on Ubuntu 22.04 with PPA-style APT packages and have <code>node<\/code> and <code>npm<\/code> ready in about ten minutes. You will add NodeSource\u2019s signed repository, install the current Node.js release, and run a loopback-only HTTP test without opening a public application port.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>A 64-bit Ubuntu 22.04 LTS server with at least 1 GB of RAM and 2 GB of free disk space for Node.js, npm, and a small application.<\/li>\n\n\n<li>SSH access as <code>root<\/code>, or a normal account with working <code>sudo<\/code> privileges.<\/li>\n\n\n<li>Outbound HTTPS access to Ubuntu package mirrors and <code>deb.nodesource.com<\/code>.<\/li>\n\n\n<li>No domain is required for this installation or its local verification test.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> if you need a root-access Ubuntu server for Node.js workloads.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The commands use <code>sudo<\/code>. If you are already logged in as <code>root<\/code>, remove <code>sudo<\/code> from the commands. This guide follows NodeSource\u2019s current-release selector, which installs the newest Node.js major available from that repository; the exact patch version will change over time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Confirm Ubuntu 22.04 and prepare APT<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Checking the release and architecture before changing APT helps prevent installing packages intended for another Ubuntu version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>. \/etc\/os-release\nprintf 'ID=%s\\nVERSION_ID=%s\\nVERSION_CODENAME=%s\\n' \"$ID\" \"$VERSION_ID\" \"$VERSION_CODENAME\"\ndpkg --print-architecture\nsudo apt-get update\nsudo apt-get install -y ca-certificates curl gnupg<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The release check should identify Ubuntu Jammy and a supported 64-bit architecture:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ID=ubuntu\nVERSION_ID=\"22.04\"\nVERSION_CODENAME=jammy\namd64<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">NodeSource also supports <code>arm64<\/code> packages. If the output is not Ubuntu <code>22.04<\/code>, stop here and use instructions for the release shown by <code>\/etc\/os-release<\/code>; do not point a Jammy system at a different distribution\u2019s repository.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Add the NodeSource current-release repository<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">NodeSource provides a signed APT repository rather than a Launchpad PPA, and its setup script creates the keyring and source configuration needed by Ubuntu 22.04.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Download the official script to a temporary file so you can see and rerun the exact local file that configures APT:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/deb.nodesource.com\/setup_current.x -o \/tmp\/nodesource_setup.sh\nsudo -E bash \/tmp\/nodesource_setup.sh\nrm -f \/tmp\/nodesource_setup.sh<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The setup output should finish by telling you to install <code>nodejs<\/code>. It currently selects the Node.js 26 repository; the selector is useful here because it follows the current release instead of leaving the server on the older Node.js 20 branch from many older tutorials. The <a href=\"https:\/\/github.com\/nodesource\/distributions#debinstall\" target=\"_blank\" rel=\"noopener\">official NodeSource Debian and Ubuntu instructions<\/a> document the supported architectures and setup process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check that APT has a NodeSource candidate before installing anything:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-cache policy nodejs | sed -n '1,9p'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see a candidate from <code>deb.nodesource.com<\/code>, with a version and major line that may be newer than this example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nodejs:\n  Installed: (none)\n  Candidate: 26.x.y-1nodesource1\n  Version table:\n *** 26.x.y-1nodesource1 600\n        600 https:\/\/deb.nodesource.com\/node_26.x nodistro\/main amd64 Packages<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>nodistro<\/code> suite in this output is normal for the current NodeSource feed. The important checks are the <code>deb.nodesource.com<\/code> origin and a non-empty candidate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install Node.js and npm<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The NodeSource <code>nodejs<\/code> package includes the runtime and npm, so one package installation provides both the JavaScript interpreter and the package manager.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install -y nodejs\nnode --version\nnpm --version\ncommand -v node\ncommand -v npm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The major version should match the current repository branch, while the npm version and patch number can change independently:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>v26.x.y\n11.x.y\n\/usr\/bin\/node\n\/usr\/bin\/npm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Ubuntu already had an older <code>nodejs<\/code> package, APT should choose the NodeSource candidate because the setup script adds the repository preference. Use <code>apt-cache policy nodejs<\/code> to confirm the selected origin if the installed major version is unexpected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Run a private Node.js HTTP test<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This temporary server checks that Node.js can load its built-in HTTP module and answer a request while binding only to localhost.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the complete test in one SSH session:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node -e 'require(\"node:http\").createServer((request, response) =&gt; response.end(\"Node.js is working on Ubuntu 22.04\\\\n\")).listen(3000, \"127.0.0.1\")' &gt;\/tmp\/node-test.log 2&gt;&amp;1 &amp;\nNODE_PID=$!\nsleep 1\ncurl -fsS http:\/\/127.0.0.1:3000\nkill \"$NODE_PID\"\nwait \"$NODE_PID\" 2&gt;\/dev\/null || true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The request should return this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Node.js is working on Ubuntu 22.04<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The process is killed at the end and port 3000 is never bound to the public network interface. For a real web application, use a dedicated service account and a TLS-enabled reverse proxy, then open only the public ports the application actually needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the Node.js installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run these checks after the test to confirm the runtime, npm, architecture, and a built-in module all work from your shell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node --version\nnpm --version\nnode -p 'process.platform + \" \" + process.arch'\nnode -e 'console.log(typeof require(\"node:fs\").readFileSync === \"function\" ? \"Built-in module check passed\" : \"Built-in module check failed\")'\napt-cache policy nodejs | sed -n '1,7p'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output includes a <code>v26<\/code> release, a numeric npm version, <code>linux amd64<\/code> or <code>linux arm64<\/code>, a passed module check, and a NodeSource candidate. For runtime APIs and supported behavior, see the <a href=\"https:\/\/nodejs.org\/api\/\" target=\"_blank\" rel=\"noopener\">official Node.js API documentation<\/a>.<\/p>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Run Node.js on Ubuntu\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">Ubuntu VPS hosting<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Run Node.js on Ubuntu<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Deploy current Node.js applications on a root-access Ubuntu 22.04 VPS.<\/p>\n\t<\/div>\n\t<a class=\"vl-cta-banner__button\" href=\"\/buy-vps\" aria-label=\"View Linux VPS plans\">View Linux VPS plans<\/a>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">APT shows Ubuntu\u2019s old Node.js version<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The setup script may not have finished, or the package lists may be stale. Check the source file, refresh APT, and inspect the candidate again:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo test -f \/etc\/apt\/sources.list.d\/nodesource.sources &amp;&amp; echo \"NodeSource source file found\"\nsudo apt-get update\napt-cache policy nodejs<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The policy output should contain <code>https:\/\/deb.nodesource.com\/node_26.x<\/code>. If it does not, rerun Step 2 and read the first error printed by the setup script before installing the Ubuntu archive version.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>Could not resolve host: deb.nodesource.com<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The VPS cannot resolve the repository hostname or cannot reach it over HTTPS. Test DNS and the outbound connection separately:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getent hosts deb.nodesource.com\ncurl -I https:\/\/deb.nodesource.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An address from <code>getent<\/code> and an HTTPS response header indicate that the path is available. If either command fails, fix the server\u2019s resolver, network route, or provider-level egress restriction and then repeat Step 2.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>Could not get lock \/var\/lib\/dpkg\/lock-frontend<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Another package operation, often Ubuntu\u2019s unattended upgrades, is using the APT database. Wait for it to finish instead of deleting the lock file, then repair any interrupted package configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -ef | grep -E '[a]pt|[d]pkg|unattended'\nsudo dpkg --configure -a\nsudo apt-get install -y nodejs<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the process list still shows an active package operation, wait and run the repair after it exits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>npm ERR! EACCES<\/code> during a global install<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">APT owns the system Node.js directories, so a normal user cannot write arbitrary global packages there. Install application dependencies locally inside the project instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/YOUR_APP\ncd ~\/YOUR_APP\nnpm init -y\nnpm install YOUR_PACKAGE<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>YOUR_APP<\/code> with the application directory and <code>YOUR_PACKAGE<\/code> with the dependency you need. This keeps the package files owned by your account and avoids making system directories writable. Use <code>sudo npm install -g<\/code> only when you intentionally need a system-wide command and have reviewed the package.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hardening and next steps<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Run production applications under a dedicated non-root account and a systemd service; Node.js does not need root privileges to serve an application on a high port.<\/li>\n\n\n<li>Keep the server patched with <code>sudo apt-get update &amp;&amp; sudo apt-get upgrade<\/code>, and test application compatibility before accepting a new major Node.js release.<\/li>\n\n\n<li>If the application will be public, allow only SSH, HTTP, and HTTPS in UFW. The <a href=\"https:\/\/vpslake.com\/ufw-firewall-generator\">VPSLake UFW firewall generator<\/a> can help draft a narrow ruleset for review before you apply it.<\/li>\n\n\n<li>Keep <code>package-lock.json<\/code> in version control, store secrets outside the repository, and review <code>npm audit<\/code> results before changing production dependencies.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Is NodeSource a real Ubuntu PPA?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Search results often call it a PPA, but NodeSource is a signed third-party APT repository rather than a Launchpad-hosted PPA. The setup script adds its keyring and source file so Ubuntu can verify the packages through APT.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I use the current release or Node.js LTS?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the current release when you need the newest runtime features and your dependencies support that major version. For most production services, the LTS line is the safer default; replace <code>setup_current.x<\/code> with <code>setup_lts.x<\/code> in Step 2 before running the script.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does installing <code>nodejs<\/code> also install npm?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The NodeSource package installs npm with the Node.js runtime, which is why <code>npm --version<\/code> works immediately after Step 3. Keep each application\u2019s dependencies local instead of installing them globally into the APT-managed directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I update Node.js later?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For updates within the selected major line, run <code>sudo apt-get update<\/code> and then <code>sudo apt-get upgrade<\/code>. Moving between Current and LTS is a repository choice, so check your application\u2019s supported Node.js versions before changing the selector.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Is NodeSource a real Ubuntu PPA?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. Search results often call it a PPA, but NodeSource is a signed third-party APT repository rather than a Launchpad-hosted PPA. The setup script adds its keyring and source file so Ubuntu can verify the packages through APT.\"}}, {\"@type\": \"Question\", \"name\": \"Should I use the current release or Node.js LTS?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Use the current release when you need the newest runtime features and your dependencies support that major version. For most production services, the LTS line is the safer default; replace `setup_current.x` with `setup_lts.x` in Step 2 before running the script.\"}}, {\"@type\": \"Question\", \"name\": \"Does installing `nodejs` also install npm?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. The NodeSource package installs npm with the Node.js runtime, which is why `npm --version` works immediately after Step 3. Keep each application\u2019s dependencies local instead of installing them globally into the APT-managed directory.\"}}, {\"@type\": \"Question\", \"name\": \"How do I update Node.js later?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"For updates within the selected major line, run `sudo apt-get update` and then `sudo apt-get upgrade`. Moving between Current and LTS is a repository choice, so check your application\u2019s supported Node.js versions before changing the selector.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Install latest Node.js on Ubuntu 22.04 with PPA-style APT packages, verify npm, run a local test server, and fix common setup errors quickly.","protected":false},"author":1,"featured_media":1220,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[5,9],"tags":[156,64,65,101],"class_list":["post-1219","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-vps-hosting","tag-javascript","tag-nodejs","tag-npm","tag-ubuntu-22-04","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/comments?post=1219"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1219\/revisions"}],"predecessor-version":[{"id":4433,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1219\/revisions\/4433"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/1220"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=1219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=1219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=1219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}