How to install packages with npm in Node.js

Installing npm packages is fundamental for Node.js development, enabling you to leverage thousands of community libraries and tools for faster application development. As the creator of CoreUI, a widely used open-source UI library, I’ve installed countless npm packages across Node.js projects for build tools, testing frameworks, and utility libraries in enterprise applications. From my expertise, the most standard approach is to use npm install command with proper dependency classification. This method ensures proper package management, version control, and deployment optimization through correct package.json configuration.

Use npm install command to add packages as dependencies or development dependencies to your project.

npm install express # production dependency
npm install --save-dev jest # development dependency
npm install -g nodemon # global package

The npm install command downloads packages from the npm registry and adds them to your project. Regular dependencies with npm install package-name are required for production and added to the dependencies section in package.json. Development dependencies with --save-dev flag are only needed during development (testing, building) and added to devDependencies. Global packages with -g flag are installed system-wide and available as CLI commands. Always commit package.json and package-lock.json for consistent dependency versions across environments.

Best Practice Note:

This is the same approach we use for managing CoreUI project dependencies and ensuring consistent builds across development teams. Use npm ci instead of npm install in production and CI environments for faster, reliable installs from package-lock.json, and regularly audit dependencies with npm audit for security vulnerabilities.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author