Local Vs Global Packaging

Omkar Bhavare
2 min readNov 9, 2023

--

Node.js includes a useful tool known as npm, serving as the standard package manager. It simplifies the process of downloading and managing dependencies for Node.js packages.

📚 To know more about npm, check out the blog 👇

npm categorizes packages into two types: local and global. This blog will extensively explore local and global packages, shedding light on their meanings, advantages, and offering detailed, step-by-step instructions for installing them through npm. 📝

📦 Local Package:

Local packages in Node.js refer to dependencies that are specific to a particular project.Installing packages locally means that they’re meant only for use within that project, keeping everything organized and separate from other projects.

🖋️ Install the Package Locally

npm install <package-name>
// Installing pacakge locally acts as a dependency
"dependencies": {
"ejs": "^3.1.9",
"is-odd": "^3.0.1",
"react": "^18.2.0",
"tailwindcss": "^3.3.5"
},

💻 Global Package:

Global packages in Node.js are like tools that you install on your computer and can use across different projects. When you install a package globally, it’s available system-wide and isn’t tied to a specific project.

🖋️ Install the Package Globally

npm install -g <package-name>

Packages which are installed globally does not show up in package.json or package-lock.json files.

If you want to see globally installed packages on your system, you can use the following command:

npm list -g --depth=0

🤔 But what if I need to Uninstall this packages ?

💡 Simply navigate to your project & run the following commands

npm uninstall <package-name>  // For Local Package

npm uninstall -g <package-name> // For Global Package

🧐 There are different types of dependencies which we need to understand to further clarify how packages works. Which is covered in below blog 👇

🤗 In conclusion, Local Node.js packages are project-specific tools, ensuring dependencies stay organized within one project. On the other hand, Global packages are like system-wide tools accessible across projects, with installations not reflected in project files. For more insights, refer to our blog on various Dependency , Semantic Versioning .

📚 Earlier Post:

What are Dependencies ? click below to know more 👇

Demystifying Semantic Vesioning 👇

🔍 Coming up next:
Async & Differ , Minification:
Tree Shaking , Transitive Dependency:

Stay tuned for more insights into the world of ReactJs development! 🚀📦

--

--

Omkar Bhavare

Passionate developer, blogger, and problem solver. Crafting code, sharing insights, and building innovative projects. 🚀