BASIC NPM COMMANDS 

What is NPM?

NPM (Node Package Manager) or node package manager, is one of the most used tools by any node.js developer since thanks to it we can have any library available with just one line of code, npm will help us manage our modules, distribute packages and add dependencies in a simple way.

Here’s a list of the most common commands you’ll use when working with NPM.

– Check NPM version.

> npm –version
> npm -v

– Get help with the following command

> npm help
> npm


– Create the package.json file.

– Create a JSON file

> npm init

– Initialize with default values.

> npm init –yes
> npm init -y


-Install a package locally or globally.

– Install a package locally.

> npm install package-name
> npm i package-name

– Install a package globally.

> npm i –global package-name
> npm i -g package-name

– Install a specific version of a package.

> npm i package-name@version

– Install a package as a development dependency.

> npm i –save-dev package-name
> npm i -D package-name


-Uninstall a package.

> npm uninstall package-name
> npm a package-name


-List project dependencies.

– List all the dependencies of your project.

> npm list
> npm ls

– List direct dependencies.

> npm list –depht=0
> npm list -g –depht=0

– Information about a project package.

> npm view package-name


– Update Packages

– Update a package

> npm update package-name
> npm up package-name

– Update global packages

> npm update -g

– Check for outdated packages

> npm outdated


Thanks for reading!

Gastón Danielsen

Full stack developer