 {"id":519694,"date":"2024-07-12T19:53:00","date_gmt":"2024-07-13T02:53:00","guid":{"rendered":"https:\/\/jorgep.com\/blog\/?p=519694"},"modified":"2026-01-03T20:03:29","modified_gmt":"2026-01-04T03:03:29","slug":"dev-log-what-is-npm-how-it-works-and-why-it-matters","status":"publish","type":"post","link":"https:\/\/jorgep.com\/blog\/dev-log-what-is-npm-how-it-works-and-why-it-matters\/","title":{"rendered":"Dev Log: What Is NPM? How It Works and Why It Matters"},"content":{"rendered":"<style>.wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84, .wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84[data-kb-block=\"kb-adv-heading519190_4a1b6f-84\"]{font-size:var(--global-kb-font-size-sm, 0.9rem);font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84[data-kb-block=\"kb-adv-heading519190_4a1b6f-84\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading519190_4a1b6f-84[data-kb-block=\"kb-adv-heading519190_4a1b6f-84\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<p class=\"kt-adv-heading519190_4a1b6f-84 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading519190_4a1b6f-84\">AI Disclaimer I love exploring new technology, and that includes using AI to help with research and editing! My digital &#8220;team&#8221; includes tools like Google Gemini, Notebook LM, Microsoft Copilot, Perplexity.ai, Claude.ai, and others as needed. They help me gather insights and polish content\u2014so you get the best, most up-to-date information possible.<\/p>\n\n\n\n<p><strong>NPM<\/strong> stands for <strong>Node Package Manager<\/strong>. It\u2019s the default package manager for <strong>Node.js<\/strong>, and it\u2019s used to <strong>install, share, and manage JavaScript libraries and tools<\/strong>. Developers use npm to pull in reusable code (packages), manage project dependencies, and run scripts for building, testing, or running apps.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">What Is NPM? A Deep Dive Into How It Works and Why It Matters<\/h1>\n\n\n\n<p>If you\u2019ve worked with JavaScript or Node.js, you\u2019ve almost certainly encountered <strong>npm<\/strong>. It\u2019s one of the most important tools in modern JavaScript development\u2014but many developers use it daily without fully understanding how it works or why it became so essential.<\/p>\n\n\n\n<p>This post explains <strong>what npm is<\/strong>, <strong>where it came from<\/strong>, <strong>how it works behind the scenes<\/strong>, and <strong>the benefits it brings to developers and teams<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is NPM?<\/h2>\n\n\n\n<p><strong>npm<\/strong> stands for <strong>Node Package Manager<\/strong>. It is the <strong>default package manager for Node.js<\/strong> and is used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install and manage JavaScript libraries (packages)<\/li>\n\n\n\n<li>Handle project dependencies<\/li>\n\n\n\n<li>Run development and build scripts<\/li>\n\n\n\n<li>Share reusable code with others<\/li>\n<\/ul>\n\n\n\n<p>npm consists of <strong>three main components<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The <strong>npm registry<\/strong> (an online package database)<\/li>\n\n\n\n<li>The <strong>npm CLI<\/strong> (the command-line tool)<\/li>\n\n\n\n<li>Project metadata files like <code>package.json<\/code> and <code>package-lock.json<\/code><\/li>\n<\/ol>\n\n\n\n<p>Together, these form the backbone of how JavaScript projects are built and maintained today.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Benefits of Using NPM<\/h2>\n\n\n\n<p>npm is more than just a package installer\u2014it is a foundational tool that enables modern JavaScript development. By standardizing how dependencies are shared, installed, and maintained, npm helps developers build applications faster, collaborate more effectively, and keep projects reliable over time. The table below highlights the key benefits npm provides to individual developers and development teams.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Benefit<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong>Massive Ecosystem<\/strong><\/td><td>Access to millions of open-source JavaScript packages, covering everything from small utilities to full frameworks.<\/td><\/tr><tr><td><strong>Faster Development<\/strong><\/td><td>Developers can reuse existing solutions instead of writing everything from scratch, dramatically speeding up development.<\/td><\/tr><tr><td><strong>Reliable Dependency Management<\/strong><\/td><td><code>package.json<\/code> and <code>package-lock.json<\/code> ensure consistent dependency versions across machines and environments.<\/td><\/tr><tr><td><strong>Easy Project Setup<\/strong><\/td><td>A new project can be set up quickly, and all dependencies can be installed with a single <code>npm install<\/code> command.<\/td><\/tr><tr><td><strong>Built-In Task Automation<\/strong><\/td><td>npm scripts allow developers to run builds, tests, and other tasks without extra tooling.<\/td><\/tr><tr><td><strong>Cross-Platform Support<\/strong><\/td><td>Works the same way on Windows, macOS, and Linux, making collaboration easier across teams.<\/td><\/tr><tr><td><strong>Version Control for Dependencies<\/strong><\/td><td>Supports semantic versioning, enabling safe upgrades, rollbacks, and controlled updates.<\/td><\/tr><tr><td><strong>Security Tools<\/strong><\/td><td>Built-in commands like <code>npm audit<\/code> help identify known vulnerabilities in dependencies.<\/td><\/tr><tr><td><strong>Industry Standard<\/strong><\/td><td>Ships with Node.js and is supported by major frameworks, tools, and hosting platforms.<\/td><\/tr><tr><td><strong>Strong Community Support<\/strong><\/td><td>Backed by a large and active community, with extensive documentation and long-term maintenance<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Brief History of NPM<\/h2>\n\n\n\n<p>To understand npm, it helps to understand its origins.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>2009<\/strong> \u2013 Node.js is released<\/li>\n\n\n\n<li><strong>2010<\/strong> \u2013 npm is created by <strong>Isaac Z. Schlueter<\/strong><\/li>\n\n\n\n<li><strong>2011<\/strong> \u2013 npm 1.0 is released<\/li>\n\n\n\n<li><strong>Late 2011<\/strong> \u2013 Node.js (and npm) gain official Windows support<\/li>\n<\/ul>\n\n\n\n<p>Before npm, JavaScript developers often manually downloaded libraries and included them directly in projects. npm introduced a <strong>standardized, automated way<\/strong> to install, update, and share code.<\/p>\n\n\n\n<p>Today, npm has been around for <strong>over 15 years<\/strong> and is considered an industry standard.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How NPM Works<\/h2>\n\n\n\n<p>At a high level, npm automates the process of <strong>finding, downloading, organizing, and updating code dependencies<\/strong>.<\/p>\n\n\n\n<p>Let\u2019s break that down.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. The npm Registry<\/h2>\n\n\n\n<p>The <strong>npm registry<\/strong> is a massive public online database of JavaScript packages.<\/p>\n\n\n\n<p>Each package typically contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JavaScript source code<\/li>\n\n\n\n<li>A <code>package.json<\/code> file<\/li>\n\n\n\n<li>Version information<\/li>\n\n\n\n<li>Dependency definitions<\/li>\n<\/ul>\n\n\n\n<p>When you run a command like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install express\n<\/code><\/pre>\n\n\n\n<p>npm:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Searches the registry for <code>express<\/code><\/li>\n\n\n\n<li>Downloads the correct version<\/li>\n\n\n\n<li>Stores it locally in your project<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">2. <code>package.json<\/code>: The Heart of a Project<\/h2>\n\n\n\n<p>Every npm-based project has a <strong><code>package.json<\/code><\/strong> file. This file acts as a <strong>contract<\/strong> that describes your project.<\/p>\n\n\n\n<p>It defines:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Project name and version<\/li>\n\n\n\n<li>Dependencies and devDependencies<\/li>\n\n\n\n<li>Scripts you can run<\/li>\n\n\n\n<li>Metadata like license and author<\/li>\n<\/ul>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"name\": \"my-app\",\n  \"version\": \"1.0.0\",\n  \"dependencies\": {\n    \"express\": \"^4.18.0\"\n  },\n  \"scripts\": {\n    \"start\": \"node index.js\"\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>npm reads this file to determine:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What needs to be installed<\/li>\n\n\n\n<li>Which versions are allowed<\/li>\n\n\n\n<li>How to run project-specific commands<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. Installing Dependencies<\/h2>\n\n\n\n<p>When you run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install\n<\/code><\/pre>\n\n\n\n<p>npm performs several steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Reads <code>package.json<\/code><\/li>\n\n\n\n<li>Resolves compatible versions of all dependencies<\/li>\n\n\n\n<li>Downloads them from the registry<\/li>\n\n\n\n<li>Places them in the <code>node_modules\/<\/code> directory<\/li>\n\n\n\n<li>Records exact versions in <code>package-lock.json<\/code><\/li>\n<\/ol>\n\n\n\n<p>This ensures consistent installs across machines and environments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Dependency Resolution and <code>package-lock.json<\/code><\/h2>\n\n\n\n<p>Most packages depend on <strong>other packages<\/strong>, which may depend on even more packages. npm builds a <strong>dependency tree<\/strong> to manage this complexity.<\/p>\n\n\n\n<p>The <code>package-lock.json<\/code> file:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locks exact versions of every dependency<\/li>\n\n\n\n<li>Ensures reproducible installs<\/li>\n\n\n\n<li>Prevents \u201cworks on my machine\u201d problems<\/li>\n<\/ul>\n\n\n\n<p>If two developers run <code>npm install<\/code>, they\u2019ll get <strong>the same dependency versions<\/strong>, even months later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. npm Scripts<\/h2>\n\n\n\n<p>npm isn\u2019t just for installing packages\u2014it\u2019s also a <strong>task runner<\/strong>.<\/p>\n\n\n\n<p>In <code>package.json<\/code>, you can define scripts like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"scripts\": {\n  \"start\": \"node index.js\",\n  \"test\": \"jest\",\n  \"build\": \"webpack\"\n}\n<\/code><\/pre>\n\n\n\n<p>You run these with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run build\n<\/code><\/pre>\n\n\n\n<p>This makes tooling:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Consistent across teams<\/li>\n\n\n\n<li>Easy to automate in CI\/CD pipelines<\/li>\n\n\n\n<li>Cross-platform (same commands on Windows, macOS, and Linux)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">When Did NPM Come to Windows?<\/h2>\n\n\n\n<p>Early versions of Node.js and npm focused on Unix-like systems.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Late 2011<\/strong> \u2013 Node.js v0.6 introduced official Windows support<\/li>\n\n\n\n<li>npm worked on Windows as soon as Node.js did<\/li>\n\n\n\n<li>Over time, Windows support became first-class<\/li>\n<\/ul>\n\n\n\n<p>Today, npm works <strong>equally well on Windows, macOS, and Linux<\/strong>, making it ideal for cross-platform development.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why NPM Matters<\/h2>\n\n\n\n<p>In simple terms:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>npm makes JavaScript development scalable.<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>It allows developers to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Share code efficiently<\/li>\n\n\n\n<li>Manage complex dependency trees<\/li>\n\n\n\n<li>Build consistent, repeatable projects<\/li>\n\n\n\n<li>Collaborate across teams and platforms<\/li>\n<\/ul>\n\n\n\n<p>Without npm (or a similar package manager), modern JavaScript development as we know it would not be possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p>npm has grown from a simple package installer into a <strong>core pillar of the JavaScript ecosystem<\/strong>. Whether you\u2019re building a small script or a large production application, npm plays a critical role in keeping your workflow fast, reliable, and maintainable.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Hope this helps! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>NPM stands for Node Package Manager. It\u2019s the default package manager for Node.js, and it\u2019s used to install, share, and manage JavaScript libraries and tools. Developers use npm to pull in reusable code (packages), manage project dependencies, and run scripts for building, testing, or running apps. What Is NPM? A Deep Dive Into How It&#8230;<\/p>\n","protected":false},"author":2,"featured_media":519697,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","ngg_post_thumbnail":0,"episode_type":"","audio_file":"","podmotor_file_id":"","podmotor_episode_id":"","cover_image":"","cover_image_id":"","duration":"","filesize":"","filesize_raw":"","date_recorded":"","explicit":"","block":"","itunes_episode_number":"","itunes_title":"","itunes_season_number":"","itunes_episode_type":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[441,446],"tags":[1015,431,168],"class_list":["post-519694","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-talk","category-tips-tools-resources","tag-devlog","tag-devops","tag-tools-tips"],"taxonomy_info":{"category":[{"value":441,"label":"Tech Talk"},{"value":446,"label":"Tips, Tools &amp; Resources"}],"post_tag":[{"value":1015,"label":"DevLog"},{"value":431,"label":"DevOps"},{"value":168,"label":"Tools &amp; Tips"}]},"featured_image_src_large":["https:\/\/jorgep.com\/blog\/wp-content\/uploads\/FeatureImage-npm-nodejs-PackageManager.png",1024,512,false],"author_info":{"display_name":"Jorge Pereira","author_link":"https:\/\/jorgep.com\/blog\/author\/jorge\/"},"comment_info":0,"category_info":[{"term_id":441,"name":"Tech Talk","slug":"tech-talk","term_group":0,"term_taxonomy_id":451,"taxonomy":"category","description":"","parent":0,"count":671,"filter":"raw","cat_ID":441,"category_count":671,"category_description":"","cat_name":"Tech Talk","category_nicename":"tech-talk","category_parent":0},{"term_id":446,"name":"Tips, Tools &amp; Resources","slug":"tips-tools-resources","term_group":0,"term_taxonomy_id":456,"taxonomy":"category","description":"","parent":0,"count":79,"filter":"raw","cat_ID":446,"category_count":79,"category_description":"","cat_name":"Tips, Tools &amp; Resources","category_nicename":"tips-tools-resources","category_parent":0}],"tag_info":[{"term_id":1015,"name":"DevLog","slug":"devlog","term_group":0,"term_taxonomy_id":1025,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":431,"name":"DevOps","slug":"devops","term_group":0,"term_taxonomy_id":441,"taxonomy":"post_tag","description":"","parent":0,"count":4,"filter":"raw"},{"term_id":168,"name":"Tools &amp; Tips","slug":"tools-tips","term_group":0,"term_taxonomy_id":180,"taxonomy":"post_tag","description":"","parent":0,"count":64,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/posts\/519694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/comments?post=519694"}],"version-history":[{"count":3,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/posts\/519694\/revisions"}],"predecessor-version":[{"id":519698,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/posts\/519694\/revisions\/519698"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/media\/519697"}],"wp:attachment":[{"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/media?parent=519694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/categories?post=519694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jorgep.com\/blog\/wp-json\/wp\/v2\/tags?post=519694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}